diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 68509282..8a31be54 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,13 +10,13 @@ jobs: matrix: configuration: ["Debug", "Release"] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: - node-version: 16.11.1 - - uses: actions/setup-dotnet@v1.7.2 + node-version: 18 + - uses: actions/setup-dotnet@v3 with: - dotnet-version: 2.1.816 + dotnet-version: '8.0.x' - run: yarn --ci working-directory: ./Source/SmallBasic.Client - run: dotnet restore diff --git a/.github/workflows/master_smallbasic-publicwebsite-code.yml b/.github/workflows/master_smallbasic-publicwebsite-code.yml index b60c4f38..5e6dacef 100644 --- a/.github/workflows/master_smallbasic-publicwebsite-code.yml +++ b/.github/workflows/master_smallbasic-publicwebsite-code.yml @@ -1,53 +1,53 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# More GitHub Actions for Azure: https://github.com/Azure/actions - -name: Build and deploy to Caseysc`s Azure Web App - smallbasic-publicwebsite-code - -on: - push: - branches: - - master - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 16.11.1 - - uses: actions/setup-dotnet@v1.7.2 - with: - dotnet-version: 2.1.816 - - run: yarn --ci - working-directory: ./Source/SmallBasic.Client - - run: dotnet restore - - run: dotnet build ./SmallBasic.sln /p:TreatWarningsAsErrors=True /p:Configuration=Release - - run: dotnet publish ./Source/SmallBasic.Editor/SmallBasic.Editor.csproj --no-build /p:TreatWarningsAsErrors=True /p:Configuration=Release - - uses: actions/upload-artifact@v3.1.0 - with: - path: /home/runner/work/smallbasic-editor/smallbasic-editor/Source/SmallBasic.Editor/bin/Release/netstandard2.0/publish/ - if-no-files-found: error - - deploy: - runs-on: windows-latest - needs: build - environment: - name: 'Production' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - - steps: - - name: Download artifact from build job - uses: actions/download-artifact@v2 - with: - name: artifact - - - name: Deploy to Azure Web App - id: deploy-to-webapp - uses: azure/webapps-deploy@v2 - with: - app-name: 'smallbasic-publicwebsite-code' - slot-name: 'Production' - publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_CC78D407C64043A1978FBF8A5FEDA312 }} - package: . +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy to Caseysc`s Azure Web App - smallbasic-publicwebsite-code + +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + - run: yarn --ci + working-directory: ./Source/SmallBasic.Client + - run: dotnet restore + - run: dotnet build ./SmallBasic.sln /p:TreatWarningsAsErrors=True /p:Configuration=Release + - run: dotnet publish ./Source/SmallBasic.Editor/SmallBasic.Editor.csproj --no-build /p:TreatWarningsAsErrors=True /p:Configuration=Release + - uses: actions/upload-artifact@v3.1.0 + with: + path: /home/runner/work/smallbasic-editor/smallbasic-editor/Source/SmallBasic.Editor/bin/Release/netstandard2.0/publish/ + if-no-files-found: error + + deploy: + runs-on: windows-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v3 + with: + name: artifact + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'smallbasic-publicwebsite-code' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_CC78D407C64043A1978FBF8A5FEDA312 }} + package: . diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..7e9a2607 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,67 @@ +name: Release Standalone Binaries and IDE + +on: + release: + types: [published, created] + push: + tags: + - '*' + - 'v*' + workflow_dispatch: + +jobs: + build-release: + name: Build Standalone Release (${{ matrix.target.os }}) + runs-on: ${{ matrix.target.runner }} + strategy: + matrix: + target: + - os: win-x64 + runner: windows-latest + asset: smallbasic-win-x64.zip + - os: linux-x64 + runner: ubuntu-latest + asset: smallbasic-linux-x64.tar.gz + - os: osx-x64 + runner: macos-latest + asset: smallbasic-macos-x64.tar.gz + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node.js 18 + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Setup .NET 8 SDK + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Restore Node Packages for Webpack + run: yarn --ci + working-directory: ./Source/SmallBasic.Client + + - name: Publish Self-Contained CLI / Compiler + run: dotnet publish Source/SmallBasic.Cli/SmallBasic.Cli.csproj -c Release -r ${{ matrix.target.os }} --self-contained true /p:PublishSingleFile=true -o dist/${{ matrix.target.os }} + + - name: Publish Editor / IDE + run: dotnet publish Source/SmallBasic.Editor/SmallBasic.Editor.csproj -c Release -o dist/${{ matrix.target.os }}/editor + + - name: Package Release Assets (Windows) + if: matrix.target.runner == 'windows-latest' + run: Compress-Archive -Path dist/${{ matrix.target.os }}/* -DestinationPath ${{ matrix.target.asset }} + + - name: Package Release Assets (Unix) + if: matrix.target.runner != 'windows-latest' + run: tar -czvf ${{ matrix.target.asset }} -C dist/${{ matrix.target.os }} . + + - name: Attach Assets to GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: ${{ matrix.target.asset }} + tag_name: ${{ github.event.release.tag_name || github.ref_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index fd3348bb..f4428095 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,10 @@ # Output files bin obj +dist/ node_modules wwwroot +*.exe +*.dll +*.pdb +*.runtimeconfig.json diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 00000000..b109b3fb --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,8 @@ + + + false + none + direct + NU1901;NU1902;NU1903;NU1904;NETSDK1138 + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 00000000..f4641260 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,16 @@ + + + false + none + direct + $(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904;NETSDK1138 + $(NoWarn);NU1901;NU1902;NU1903;NU1904;NETSDK1138 + + + + + $(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904;NETSDK1138 + $(NoWarn);NU1901;NU1902;NU1903;NU1904;NETSDK1138 + + + diff --git a/LANGUAGE_EXTENSIONS.md b/LANGUAGE_EXTENSIONS.md new file mode 100644 index 00000000..e90fa61c --- /dev/null +++ b/LANGUAGE_EXTENSIONS.md @@ -0,0 +1,128 @@ +# Small Basic Language Extensions Documentation + +This repository contains modern, powerful extensions to the Small Basic compiler and runtime. Below is a comprehensive guide to all newly added language features, control flow constructs, file module imports, and .NET interop libraries. + +--- + +## 1. Functions with Parameters and Return Statements + +Small Basic now supports standard parameter-passing subroutines and functions with return values. + +### Keywords +- `Function` or `Fn` +- `EndFunction` or `EndFn` +- `Return` + +### Syntax & Examples + +```smallbasic +Function Add(a, b) + Return a + b +EndFunction + +sum = Add(15, 25) ' sum = 40 +``` + +Recursive functions are fully supported: + +```smallbasic +Fn Factorial(n) + If n <= 1 Then + Return 1 + EndIf + Return n * Factorial(n - 1) +EndFn + +result = Factorial(5) ' result = 120 +``` + +--- + +## 2. File Module Import System (`Import`) + +Organize Small Basic code into modular files using relative or absolute path imports. + +### Syntax +```smallbasic +Import "helpers/math_utils.sb" + +res = Square(6) +``` + +Imports are recursively resolved relative to the current file's directory path. Cyclic imports are automatically detected and safely skipped. + +--- + +## 3. Control Flow Constructs + +### A. `Select Case` Statements +Replace long `If/ElseIf` chains with clean pattern matching: + +```smallbasic +val = 2 + +Select Case val + Case 1 + TextWindow.WriteLine("One") + Case 2 + TextWindow.WriteLine("Two") + Else + TextWindow.WriteLine("Other") +EndSelect +``` + +### B. `Try / Catch / Finally` Error Handling +Handle errors gracefully without terminating execution: + +```smallbasic +Try + res = File.ReadContents("data.txt") +Catch ex + res = "Default Content" +Finally + TextWindow.WriteLine("Completed read attempt.") +EndTry +``` + +### C. `ForEach` Loops +Iterate over collections easily: + +```smallbasic +ForEach item In list + TextWindow.WriteLine(item) +EndFor +``` + +--- + +## 4. .NET / C# Reflection Interop (`System` Library) + +Directly invoke static methods and read static properties from any available .NET type directly in Small Basic code. + +### Methods +- `System.Call(typeName, methodName, argument)` +- `System.GetProperty(typeName, propertyName)` +- `System.Exists(filePath)` + +### Example Usage + +```smallbasic +' Call System.Math.Abs +absVal = System.Call("System.Math", "Abs", -42) ' returns 42 + +' Access .NET System.Environment property +os = System.GetProperty("System.Environment", "OSVersion") +``` + +--- + +## 5. Extended Math Utilities (`Math` Library) + +- `Math.Clamp(value, min, max)`: Clamps `value` between `min` and `max`. +- `Math.Lerp(start, end, amount)`: Performs linear interpolation between `start` and `end`. +- `Math.Atan2(y, x)`: Returns the 2-argument arctangent of `y` and `x`. + +--- + +## Summary of All Added Keywords +`Function`, `Fn`, `EndFunction`, `EndFn`, `Return`, `Import`, `Select`, `Case`, `EndSelect`, `Try`, `Catch`, `Finally`, `EndTry`, `ForEach`, `In`. diff --git a/README.md b/README.md index 134c8c39..6f2a5bc5 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ This is home to the new SmallBasic editor. It has the following projects: * **SmallBasic.Tests**: C# unit tests to test the compiler/engine. * **SmallBasic.Utilities**: helper utilities shared between different projects. +#### Language Extensions & New Features +For complete details and code examples of newly added compiler features (Functions with parameters/returns, relative module `Import`, `Select Case`, `Try/Catch/Finally`, `ForEach`, `Math` extensions, and `System.Call` .NET reflection interop), see [LANGUAGE_EXTENSIONS.md](LANGUAGE_EXTENSIONS.md). + #### Developer Workflow 1. Open **SmallBasic.sln** in Visual Studio 2017. diff --git a/Source/Directory.Build.props b/Source/Directory.Build.props index 84094dd5..a78fad9d 100644 --- a/Source/Directory.Build.props +++ b/Source/Directory.Build.props @@ -16,6 +16,7 @@ + diff --git a/Source/SmallBasic.Bridge/Bridge.Generated.cs b/Source/SmallBasic.Bridge/Bridge.Generated.cs index 1e1355fc..e31df342 100644 --- a/Source/SmallBasic.Bridge/Bridge.Generated.cs +++ b/Source/SmallBasic.Bridge/Bridge.Generated.cs @@ -1,256 +1,256 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Bridge -{ - using System.Diagnostics; - using Newtonsoft.Json; - using SmallBasic.Utilities; - using SmallBasic.Utilities.Bridge; - - internal interface IProcessBridge - { - void OpenExternalLink(string url); - } - - internal interface IFileBridge - { - FileBridgeModels.Result AppendContents(FileBridgeModels.PathAndContentsArgs args); - - FileBridgeModels.Result CopyFile(FileBridgeModels.SourceAndDestinationArgs args); - - FileBridgeModels.Result CreateDirectory(string directoryPath); - - FileBridgeModels.Result DeleteDirectory(string directoryPath); - - FileBridgeModels.Result DeleteFile(string filePath); - - FileBridgeModels.Result GetDirectories(string directoryPath); - - FileBridgeModels.Result GetFiles(string directoryPath); - - FileBridgeModels.Result GetTemporaryFilePath(); - - FileBridgeModels.Result InsertLine(FileBridgeModels.PathAndLineAndContentsArgs args); - - FileBridgeModels.Result ReadContents(string filePath); - - FileBridgeModels.Result ReadLine(FileBridgeModels.PathAndLineArgs args); - - FileBridgeModels.Result WriteContents(FileBridgeModels.PathAndContentsArgs args); - - FileBridgeModels.Result WriteLine(FileBridgeModels.PathAndLineAndContentsArgs args); - } - - internal interface INetworkBridge - { - ImageListBridgeModels.ImageData LoadImage(string fileNameOrUrl); - - string DownloadFile(string url); - - string GetWebPageContents(string url); - } - - internal static class BridgeExecution - { - private static readonly IProcessBridge Process = new ProcessBridge(); - - private static readonly IFileBridge File = new FileBridge(); - - private static readonly INetworkBridge Network = new NetworkBridge(); - - public static void Run(string[] args) - { - Debug.Assert(args.Length >= 2, "Only intended for bridge calls"); - - string type = args[0]; - string method = args[1]; - string filePath = args.Length > 2 ? args[2] : null; - - switch (type) - { - case "Process": - { - switch (method) - { - case "OpenExternalLink": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - Process.OpenExternalLink(input); - break; - } - - default: - { - throw ExceptionUtilities.UnexpectedValue(method); - } - } - - break; - } - - case "File": - { - switch (method) - { - case "AppendContents": - { - FileBridgeModels.PathAndContentsArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.AppendContents(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "CopyFile": - { - FileBridgeModels.SourceAndDestinationArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.CopyFile(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "CreateDirectory": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.CreateDirectory(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "DeleteDirectory": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.DeleteDirectory(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "DeleteFile": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.DeleteFile(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "GetDirectories": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.GetDirectories(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "GetFiles": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.GetFiles(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "GetTemporaryFilePath": - { - FileBridgeModels.Result output = File.GetTemporaryFilePath(); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "InsertLine": - { - FileBridgeModels.PathAndLineAndContentsArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.InsertLine(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "ReadContents": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.ReadContents(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "ReadLine": - { - FileBridgeModels.PathAndLineArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.ReadLine(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "WriteContents": - { - FileBridgeModels.PathAndContentsArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.WriteContents(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "WriteLine": - { - FileBridgeModels.PathAndLineAndContentsArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - FileBridgeModels.Result output = File.WriteLine(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - default: - { - throw ExceptionUtilities.UnexpectedValue(method); - } - } - - break; - } - - case "Network": - { - switch (method) - { - case "LoadImage": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - ImageListBridgeModels.ImageData output = Network.LoadImage(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "DownloadFile": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - string output = Network.DownloadFile(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - case "GetWebPageContents": - { - string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); - string output = Network.GetWebPageContents(input); - System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); - break; - } - - default: - { - throw ExceptionUtilities.UnexpectedValue(method); - } - } - - break; - } - - default: - { - throw ExceptionUtilities.UnexpectedValue(type); - } - } - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Bridge +{ + using System.Diagnostics; + using Newtonsoft.Json; + using SmallBasic.Utilities; + using SmallBasic.Utilities.Bridge; + + internal interface IProcessBridge + { + void OpenExternalLink(string url); + } + + internal interface IFileBridge + { + FileBridgeModels.Result AppendContents(FileBridgeModels.PathAndContentsArgs args); + + FileBridgeModels.Result CopyFile(FileBridgeModels.SourceAndDestinationArgs args); + + FileBridgeModels.Result CreateDirectory(string directoryPath); + + FileBridgeModels.Result DeleteDirectory(string directoryPath); + + FileBridgeModels.Result DeleteFile(string filePath); + + FileBridgeModels.Result GetDirectories(string directoryPath); + + FileBridgeModels.Result GetFiles(string directoryPath); + + FileBridgeModels.Result GetTemporaryFilePath(); + + FileBridgeModels.Result InsertLine(FileBridgeModels.PathAndLineAndContentsArgs args); + + FileBridgeModels.Result ReadContents(string filePath); + + FileBridgeModels.Result ReadLine(FileBridgeModels.PathAndLineArgs args); + + FileBridgeModels.Result WriteContents(FileBridgeModels.PathAndContentsArgs args); + + FileBridgeModels.Result WriteLine(FileBridgeModels.PathAndLineAndContentsArgs args); + } + + internal interface INetworkBridge + { + ImageListBridgeModels.ImageData LoadImage(string fileNameOrUrl); + + string DownloadFile(string url); + + string GetWebPageContents(string url); + } + + internal static class BridgeExecution + { + private static readonly IProcessBridge Process = new ProcessBridge(); + + private static readonly IFileBridge File = new FileBridge(); + + private static readonly INetworkBridge Network = new NetworkBridge(); + + public static void Run(string[] args) + { + Debug.Assert(args.Length >= 2, "Only intended for bridge calls"); + + string type = args[0]; + string method = args[1]; + string filePath = args.Length > 2 ? args[2] : null; + + switch (type) + { + case "Process": + { + switch (method) + { + case "OpenExternalLink": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + Process.OpenExternalLink(input); + break; + } + + default: + { + throw ExceptionUtilities.UnexpectedValue(method); + } + } + + break; + } + + case "File": + { + switch (method) + { + case "AppendContents": + { + FileBridgeModels.PathAndContentsArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.AppendContents(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "CopyFile": + { + FileBridgeModels.SourceAndDestinationArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.CopyFile(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "CreateDirectory": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.CreateDirectory(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "DeleteDirectory": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.DeleteDirectory(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "DeleteFile": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.DeleteFile(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "GetDirectories": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.GetDirectories(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "GetFiles": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.GetFiles(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "GetTemporaryFilePath": + { + FileBridgeModels.Result output = File.GetTemporaryFilePath(); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "InsertLine": + { + FileBridgeModels.PathAndLineAndContentsArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.InsertLine(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "ReadContents": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.ReadContents(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "ReadLine": + { + FileBridgeModels.PathAndLineArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.ReadLine(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "WriteContents": + { + FileBridgeModels.PathAndContentsArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.WriteContents(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "WriteLine": + { + FileBridgeModels.PathAndLineAndContentsArgs input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + FileBridgeModels.Result output = File.WriteLine(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + default: + { + throw ExceptionUtilities.UnexpectedValue(method); + } + } + + break; + } + + case "Network": + { + switch (method) + { + case "LoadImage": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + ImageListBridgeModels.ImageData output = Network.LoadImage(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "DownloadFile": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + string output = Network.DownloadFile(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + case "GetWebPageContents": + { + string input = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(filePath)); + string output = Network.GetWebPageContents(input); + System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(output)); + break; + } + + default: + { + throw ExceptionUtilities.UnexpectedValue(method); + } + } + + break; + } + + default: + { + throw ExceptionUtilities.UnexpectedValue(type); + } + } + } + } +} diff --git a/Source/SmallBasic.Cli/Program.cs b/Source/SmallBasic.Cli/Program.cs new file mode 100644 index 00000000..e0b0b9c1 --- /dev/null +++ b/Source/SmallBasic.Cli/Program.cs @@ -0,0 +1,226 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +namespace SmallBasic.Cli +{ + using System; + using System.IO; + using System.Linq; + using System.Reflection; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using SmallBasic.Compiler; + using SmallBasic.Compiler.Runtime; + + public static class Program + { + public static async Task Main(string[] args) + { + if (args.Length == 0 || args[0] == "--help" || args[0] == "-h") + { + ShowHelp(); + return 0; + } + + string command = args[0].ToUpperInvariant(); + + if (command == "RUN") + { + if (args.Length < 2) + { + Console.WriteLine("Error: Missing file path for 'run' command."); + return 1; + } + + string file = args[1]; + if (!File.Exists(file)) + { + Console.WriteLine($"Error: File '{file}' not found."); + return 1; + } + + string source = File.ReadAllText(file); + string baseDir = Path.GetDirectoryName(Path.GetFullPath(file)) ?? string.Empty; + + var compilation = new SmallBasicCompilation(source, baseDirectory: baseDir); + + if (compilation.Diagnostics.Any()) + { + Console.WriteLine("Compilation errors:"); + foreach (var diag in compilation.Diagnostics) + { + Console.WriteLine($" [{diag.Range.Start.Line + 1}:{diag.Range.Start.Column + 1}] {diag.ToDisplayString()}"); + } + + return 1; + } + + var engine = new SmallBasicEngine(compilation, new BuiltInLibraries()); + await engine.Execute().ConfigureAwait(false); + Console.WriteLine("\nProgram executed successfully."); + return 0; + } + else if (command == "BUILD") + { + if (args.Length < 2) + { + Console.WriteLine("Error: Missing file path for 'build' command."); + return 1; + } + + string file = args[1]; + if (!File.Exists(file)) + { + Console.WriteLine($"Error: File '{file}' not found."); + return 1; + } + + string outFile = "output.exe"; + for (int i = 2; i < args.Length; i++) + { + if ((args[i] == "-o" || args[i] == "--output") && i + 1 < args.Length) + { + outFile = args[i + 1]; + } + } + + Console.WriteLine($"Building '{file}' into standalone executable '{outFile}'..."); + string source = File.ReadAllText(file); + string baseDir = Path.GetDirectoryName(Path.GetFullPath(file)) ?? string.Empty; + var compilation = new SmallBasicCompilation(source, baseDirectory: baseDir); + + if (compilation.Diagnostics.Any()) + { + Console.WriteLine("Compilation failed with errors:"); + foreach (var diag in compilation.Diagnostics) + { + Console.WriteLine($" [{diag.Range.Start.Line + 1}:{diag.Range.Start.Column + 1}] {diag.ToDisplayString()}"); + } + + return 1; + } + + string escapedSource = SymbolDisplay.FormatLiteral(source, true); + + string csharpCode = $@" +using System; +using System.Threading.Tasks; +using SmallBasic.Compiler; +using SmallBasic.Compiler.Runtime; + +namespace SmallBasicRunner +{{ + public static class Program + {{ + public static async Task Main(string[] args) + {{ + string code = {escapedSource}; + var compilation = new SmallBasicCompilation(code); + var engine = new SmallBasicEngine(compilation, new BuiltInLibraries()); + await engine.Execute(); + }} + }} +}}"; + + var parseOptions = new CSharpParseOptions(LanguageVersion.Latest); + var syntaxTree = CSharpSyntaxTree.ParseText(csharpCode, parseOptions); + + var references = new MetadataReference[] + { + MetadataReference.CreateFromFile(GetAssemblyLocation(typeof(object))), + MetadataReference.CreateFromFile(GetAssemblyLocation(typeof(Console))), + MetadataReference.CreateFromFile(GetAssemblyLocation(typeof(Task))), + MetadataReference.CreateFromFile(GetAssemblyLocation(Assembly.Load("netstandard"))), + MetadataReference.CreateFromFile(GetAssemblyLocation(Assembly.Load("System.Runtime"))), + MetadataReference.CreateFromFile(GetAssemblyLocation(typeof(SmallBasicCompilation))) + }; + + var csharpCompilation = CSharpCompilation.Create( + Path.GetFileNameWithoutExtension(outFile), + syntaxTrees: new[] { syntaxTree }, + references: references, + options: new CSharpCompilationOptions(OutputKind.ConsoleApplication)); + + var emitResult = csharpCompilation.Emit(outFile); + + if (!emitResult.Success) + { + Console.WriteLine("Failed to generate executable:"); + foreach (var diagnostic in emitResult.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error)) + { + Console.WriteLine($" {diagnostic.GetMessage()}"); + } + + return 1; + } + + // Copy compiler & utilities assemblies next to output so it runs out-of-the-box + string outDir = Path.GetDirectoryName(Path.GetFullPath(outFile)) ?? "."; + string compLoc = GetAssemblyLocation(typeof(SmallBasicCompilation)); + string utilLoc = GetAssemblyLocation(typeof(SmallBasic.Utilities.ExceptionUtilities)); + if (File.Exists(compLoc)) + { + File.Copy(compLoc, Path.Combine(outDir, Path.GetFileName(compLoc)), overwrite: true); + } + + if (File.Exists(utilLoc)) + { + File.Copy(utilLoc, Path.Combine(outDir, Path.GetFileName(utilLoc)), overwrite: true); + } + + string runtimeConfig = Path.Combine(outDir, Path.GetFileNameWithoutExtension(outFile) + ".runtimeconfig.json"); + string jsonContent = @"{ + ""runtimeOptions"": { + ""tfm"": ""net8.0"", + ""framework"": { + ""name"": ""Microsoft.NETCore.App"", + ""version"": ""8.0.0"" + } + } +}"; + File.WriteAllText(runtimeConfig, jsonContent); + + Console.WriteLine($"Successfully built executable at '{outFile}'."); + return 0; + } + else + { + ShowHelp(); + return 1; + } + } + + private static string GetAssemblyLocation(Type type) + { + string loc = type.Assembly.Location; + if (string.IsNullOrEmpty(loc)) + { + loc = Path.Combine(AppContext.BaseDirectory, type.Assembly.GetName().Name + ".dll"); + } + + return loc; + } + + private static string GetAssemblyLocation(Assembly assembly) + { + string loc = assembly.Location; + if (string.IsNullOrEmpty(loc)) + { + loc = Path.Combine(AppContext.BaseDirectory, assembly.GetName().Name + ".dll"); + } + + return loc; + } + + private static void ShowHelp() + { + Console.WriteLine("Small Basic CLI v2.0"); + Console.WriteLine("Usage:"); + Console.WriteLine(" sb run Run a Small Basic script"); + Console.WriteLine(" sb build -o Build a standalone executable"); + Console.WriteLine(" sb --help Display this help message"); + } + } +} diff --git a/Source/SmallBasic.Cli/SmallBasic.Cli.csproj b/Source/SmallBasic.Cli/SmallBasic.Cli.csproj new file mode 100644 index 00000000..c12aa736 --- /dev/null +++ b/Source/SmallBasic.Cli/SmallBasic.Cli.csproj @@ -0,0 +1,17 @@ + + + + Exe + net8.0 + enable + disable + sb + + + + + + + + + diff --git a/Source/SmallBasic.Client/Bridge/Bridge.Generated.ts b/Source/SmallBasic.Client/Bridge/Bridge.Generated.ts index e48a0aea..6b1c1c77 100644 --- a/Source/SmallBasic.Client/Bridge/Bridge.Generated.ts +++ b/Source/SmallBasic.Client/Bridge/Bridge.Generated.ts @@ -1,107 +1,107 @@ -/*! - * Licensed under the MIT License. See LICENSE file in the project root for license information. - */ - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -import * as fs from "fs"; -import * as os from "os"; -import * as path from "path"; -import * as child_process from "child_process"; - -const communicationFilePath = path.join(os.tmpdir(), `bridge-comm-${Math.random().toString().split(".")[1]}.json`); -const bridgeBinaryPath = path.resolve(__dirname, "_bridge", "SmallBasic.Bridge.dll"); - -(global).Bridge = { - Process: { - OpenExternalLink: async (url: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(url)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "Process", "OpenExternalLink", communicationFilePath]); - return true; - } - }, - File: { - AppendContents: async (args: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(args)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "AppendContents", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - CopyFile: async (args: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(args)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "CopyFile", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - CreateDirectory: async (directoryPath: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(directoryPath)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "CreateDirectory", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - DeleteDirectory: async (directoryPath: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(directoryPath)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "DeleteDirectory", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - DeleteFile: async (filePath: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(filePath)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "DeleteFile", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - GetDirectories: async (directoryPath: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(directoryPath)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "GetDirectories", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - GetFiles: async (directoryPath: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(directoryPath)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "GetFiles", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - GetTemporaryFilePath: async (): Promise => { - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "GetTemporaryFilePath", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - InsertLine: async (args: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(args)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "InsertLine", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - ReadContents: async (filePath: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(filePath)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "ReadContents", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - ReadLine: async (args: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(args)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "ReadLine", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - WriteContents: async (args: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(args)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "WriteContents", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - WriteLine: async (args: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(args)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "WriteLine", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - } - }, - Network: { - LoadImage: async (fileNameOrUrl: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(fileNameOrUrl)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "Network", "LoadImage", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - DownloadFile: async (url: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(url)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "Network", "DownloadFile", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - }, - GetWebPageContents: async (url: object): Promise => { - fs.writeFileSync(communicationFilePath, JSON.stringify(url)); - child_process.execFileSync("dotnet", [bridgeBinaryPath, "Network", "GetWebPageContents", communicationFilePath]); - return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); - } - } -}; +/*! + * Licensed under the MIT License. See LICENSE file in the project root for license information. + */ + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +import * as fs from "fs"; +import * as os from "os"; +import * as path from "path"; +import * as child_process from "child_process"; + +const communicationFilePath = path.join(os.tmpdir(), `bridge-comm-${Math.random().toString().split(".")[1]}.json`); +const bridgeBinaryPath = path.resolve(__dirname, "_bridge", "SmallBasic.Bridge.dll"); + +(global).Bridge = { + Process: { + OpenExternalLink: async (url: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(url)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "Process", "OpenExternalLink", communicationFilePath]); + return true; + } + }, + File: { + AppendContents: async (args: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(args)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "AppendContents", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + CopyFile: async (args: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(args)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "CopyFile", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + CreateDirectory: async (directoryPath: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(directoryPath)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "CreateDirectory", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + DeleteDirectory: async (directoryPath: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(directoryPath)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "DeleteDirectory", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + DeleteFile: async (filePath: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(filePath)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "DeleteFile", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + GetDirectories: async (directoryPath: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(directoryPath)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "GetDirectories", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + GetFiles: async (directoryPath: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(directoryPath)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "GetFiles", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + GetTemporaryFilePath: async (): Promise => { + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "GetTemporaryFilePath", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + InsertLine: async (args: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(args)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "InsertLine", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + ReadContents: async (filePath: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(filePath)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "ReadContents", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + ReadLine: async (args: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(args)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "ReadLine", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + WriteContents: async (args: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(args)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "WriteContents", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + WriteLine: async (args: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(args)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "File", "WriteLine", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + } + }, + Network: { + LoadImage: async (fileNameOrUrl: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(fileNameOrUrl)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "Network", "LoadImage", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + DownloadFile: async (url: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(url)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "Network", "DownloadFile", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + }, + GetWebPageContents: async (url: object): Promise => { + fs.writeFileSync(communicationFilePath, JSON.stringify(url)); + child_process.execFileSync("dotnet", [bridgeBinaryPath, "Network", "GetWebPageContents", communicationFilePath]); + return JSON.parse(fs.readFileSync(communicationFilePath, "utf8")); + } + } +}; diff --git a/Source/SmallBasic.Client/Interop/CSInterop.Generated.ts b/Source/SmallBasic.Client/Interop/CSInterop.Generated.ts index 1ff78126..196235de 100644 --- a/Source/SmallBasic.Client/Interop/CSInterop.Generated.ts +++ b/Source/SmallBasic.Client/Interop/CSInterop.Generated.ts @@ -1,45 +1,45 @@ -/*! - * Licensed under the MIT License. See LICENSE file in the project root for license information. - */ - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// - -/// - -export module CSIntrop { - export module Monaco { - export function updateDiagnostics(code: string): Promise { - return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.Monaco.UpdateDiagnostics", code); - } - - export function provideCompletionItems(code: string, position: monaco.IPosition): Promise { - return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.Monaco.ProvideCompletionItems", code, position); - } - - export function provideHover(code: string, position: monaco.IPosition): Promise { - return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.Monaco.ProvideHover", code, position); - } - } - - export module GraphicsDisplay { - export function updateDisplayLocation(x: number, y: number): Promise { - return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.GraphicsDisplay.UpdateDisplayLocation", x, y).then(() => { - Promise.resolve(); - }); - } - - export function onKeyUp(key: string): Promise { - return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.GraphicsDisplay.OnKeyUp", key).then(() => { - Promise.resolve(); - }); - } - - export function onKeyDown(key: string): Promise { - return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.GraphicsDisplay.OnKeyDown", key).then(() => { - Promise.resolve(); - }); - } - } -} +/*! + * Licensed under the MIT License. See LICENSE file in the project root for license information. + */ + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// + +/// + +export module CSIntrop { + export module Monaco { + export function updateDiagnostics(code: string): Promise { + return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.Monaco.UpdateDiagnostics", code); + } + + export function provideCompletionItems(code: string, position: monaco.IPosition): Promise { + return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.Monaco.ProvideCompletionItems", code, position); + } + + export function provideHover(code: string, position: monaco.IPosition): Promise { + return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.Monaco.ProvideHover", code, position); + } + } + + export module GraphicsDisplay { + export function updateDisplayLocation(x: number, y: number): Promise { + return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.GraphicsDisplay.UpdateDisplayLocation", x, y).then(() => { + Promise.resolve(); + }); + } + + export function onKeyUp(key: string): Promise { + return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.GraphicsDisplay.OnKeyUp", key).then(() => { + Promise.resolve(); + }); + } + + export function onKeyDown(key: string): Promise { + return DotNet.invokeMethodAsync("SmallBasic.Editor", "CSIntrop.GraphicsDisplay.OnKeyDown", key).then(() => { + Promise.resolve(); + }); + } + } +} diff --git a/Source/SmallBasic.Client/Interop/JSInterop.Generated.ts b/Source/SmallBasic.Client/Interop/JSInterop.Generated.ts index 5048dd95..3f060d98 100644 --- a/Source/SmallBasic.Client/Interop/JSInterop.Generated.ts +++ b/Source/SmallBasic.Client/Interop/JSInterop.Generated.ts @@ -1,130 +1,130 @@ -/*! - * Licensed under the MIT License. See LICENSE file in the project root for license information. - */ - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -import { LayoutInterop } from "./LayoutInterop"; -import { MonacoInterop } from "./MonacoInterop"; - -export interface ILayoutInterop { - initializeWebView(locale: string, title: string): Promise; - openExternalLink(url: string): Promise; - showMessage(title: string, text: string): Promise; - getElementHeight(element: HTMLElement): Promise; - getElementWidth(element: HTMLElement): Promise; - scrollIntoView(element: HTMLElement): Promise; - focus(element: HTMLElement): Promise; -} - -export interface IMonacoInterop { - initialize(editorElement: HTMLElement, initialValue: string, isReadOnly: boolean): Promise; - dispose(): Promise; - selectRange(range: monaco.IRange): Promise; - highlightLine(line: number): Promise; - removeDecorations(): Promise; - saveToFile(): Promise; - openFile(confirmationMessage: string): Promise; - clearEditor(confirmationMessage: string): Promise; - cut(): Promise; - copy(): Promise; - paste(): Promise; - undo(): Promise; - redo(): Promise; -} - -declare global { - export module JSInterop { - export const Layout: ILayoutInterop; - export const Monaco: IMonacoInterop; - } -} - -const layout: ILayoutInterop = new LayoutInterop(); -const monaco: IMonacoInterop = new MonacoInterop(); - -(global).JSInterop = { - Layout: { - initializeWebView: async (locale: string, title: string) : Promise => { - await layout.initializeWebView(locale, title); - return true; - }, - openExternalLink: async (url: string) : Promise => { - await layout.openExternalLink(url); - return true; - }, - showMessage: async (title: string, text: string) : Promise => { - await layout.showMessage(title, text); - return true; - }, - getElementHeight: async (element: HTMLElement) : Promise => { - return await layout.getElementHeight(element); - }, - getElementWidth: async (element: HTMLElement) : Promise => { - return await layout.getElementWidth(element); - }, - scrollIntoView: async (element: HTMLElement) : Promise => { - await layout.scrollIntoView(element); - return true; - }, - focus: async (element: HTMLElement) : Promise => { - await layout.focus(element); - return true; - } - }, - Monaco: { - initialize: async (editorElement: HTMLElement, initialValue: string, isReadOnly: boolean) : Promise => { - await monaco.initialize(editorElement, initialValue, isReadOnly); - return true; - }, - dispose: async () : Promise => { - await monaco.dispose(); - return true; - }, - selectRange: async (range: monaco.IRange) : Promise => { - await monaco.selectRange(range); - return true; - }, - highlightLine: async (line: number) : Promise => { - await monaco.highlightLine(line); - return true; - }, - removeDecorations: async () : Promise => { - await monaco.removeDecorations(); - return true; - }, - saveToFile: async () : Promise => { - await monaco.saveToFile(); - return true; - }, - openFile: async (confirmationMessage: string) : Promise => { - await monaco.openFile(confirmationMessage); - return true; - }, - clearEditor: async (confirmationMessage: string) : Promise => { - await monaco.clearEditor(confirmationMessage); - return true; - }, - cut: async () : Promise => { - await monaco.cut(); - return true; - }, - copy: async () : Promise => { - await monaco.copy(); - return true; - }, - paste: async () : Promise => { - await monaco.paste(); - return true; - }, - undo: async () : Promise => { - await monaco.undo(); - return true; - }, - redo: async () : Promise => { - await monaco.redo(); - return true; - } - } -}; +/*! + * Licensed under the MIT License. See LICENSE file in the project root for license information. + */ + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +import { LayoutInterop } from "./LayoutInterop"; +import { MonacoInterop } from "./MonacoInterop"; + +export interface ILayoutInterop { + initializeWebView(locale: string, title: string): Promise; + openExternalLink(url: string): Promise; + showMessage(title: string, text: string): Promise; + getElementHeight(element: HTMLElement): Promise; + getElementWidth(element: HTMLElement): Promise; + scrollIntoView(element: HTMLElement): Promise; + focus(element: HTMLElement): Promise; +} + +export interface IMonacoInterop { + initialize(editorElement: HTMLElement, initialValue: string, isReadOnly: boolean): Promise; + dispose(): Promise; + selectRange(range: monaco.IRange): Promise; + highlightLine(line: number): Promise; + removeDecorations(): Promise; + saveToFile(): Promise; + openFile(confirmationMessage: string): Promise; + clearEditor(confirmationMessage: string): Promise; + cut(): Promise; + copy(): Promise; + paste(): Promise; + undo(): Promise; + redo(): Promise; +} + +declare global { + export module JSInterop { + export const Layout: ILayoutInterop; + export const Monaco: IMonacoInterop; + } +} + +const layout: ILayoutInterop = new LayoutInterop(); +const monaco: IMonacoInterop = new MonacoInterop(); + +(global).JSInterop = { + Layout: { + initializeWebView: async (locale: string, title: string) : Promise => { + await layout.initializeWebView(locale, title); + return true; + }, + openExternalLink: async (url: string) : Promise => { + await layout.openExternalLink(url); + return true; + }, + showMessage: async (title: string, text: string) : Promise => { + await layout.showMessage(title, text); + return true; + }, + getElementHeight: async (element: HTMLElement) : Promise => { + return await layout.getElementHeight(element); + }, + getElementWidth: async (element: HTMLElement) : Promise => { + return await layout.getElementWidth(element); + }, + scrollIntoView: async (element: HTMLElement) : Promise => { + await layout.scrollIntoView(element); + return true; + }, + focus: async (element: HTMLElement) : Promise => { + await layout.focus(element); + return true; + } + }, + Monaco: { + initialize: async (editorElement: HTMLElement, initialValue: string, isReadOnly: boolean) : Promise => { + await monaco.initialize(editorElement, initialValue, isReadOnly); + return true; + }, + dispose: async () : Promise => { + await monaco.dispose(); + return true; + }, + selectRange: async (range: monaco.IRange) : Promise => { + await monaco.selectRange(range); + return true; + }, + highlightLine: async (line: number) : Promise => { + await monaco.highlightLine(line); + return true; + }, + removeDecorations: async () : Promise => { + await monaco.removeDecorations(); + return true; + }, + saveToFile: async () : Promise => { + await monaco.saveToFile(); + return true; + }, + openFile: async (confirmationMessage: string) : Promise => { + await monaco.openFile(confirmationMessage); + return true; + }, + clearEditor: async (confirmationMessage: string) : Promise => { + await monaco.clearEditor(confirmationMessage); + return true; + }, + cut: async () : Promise => { + await monaco.cut(); + return true; + }, + copy: async () : Promise => { + await monaco.copy(); + return true; + }, + paste: async () : Promise => { + await monaco.paste(); + return true; + }, + undo: async () : Promise => { + await monaco.undo(); + return true; + }, + redo: async () : Promise => { + await monaco.redo(); + return true; + } + } +}; diff --git a/Source/SmallBasic.Client/SmallBasic.Client.csproj b/Source/SmallBasic.Client/SmallBasic.Client.csproj index 58f28d97..1e85be0f 100644 --- a/Source/SmallBasic.Client/SmallBasic.Client.csproj +++ b/Source/SmallBasic.Client/SmallBasic.Client.csproj @@ -36,7 +36,7 @@ - + diff --git a/Source/SmallBasic.Compiler/Binding/Binder.cs b/Source/SmallBasic.Compiler/Binding/Binder.cs index 5ce445ef..dd54e4f2 100644 --- a/Source/SmallBasic.Compiler/Binding/Binder.cs +++ b/Source/SmallBasic.Compiler/Binding/Binder.cs @@ -28,6 +28,7 @@ public Binder(StatementBlockSyntax syntaxTree, DiagnosticBag diagnostics, bool i var mainModule = new List(); var subModules = new Dictionary(); + // First pass: collect submodules and functions foreach (var syntax in syntaxTree.Body) { switch (syntax) @@ -35,7 +36,7 @@ public Binder(StatementBlockSyntax syntaxTree, DiagnosticBag diagnostics, bool i case SubModuleStatementSyntax subModuleStatement: { var body = this.BindStatementBlock(subModuleStatement.Body); - var subModule = new BoundSubModule(subModuleStatement, subModuleStatement.NameToken.Text, body); + var subModule = new BoundSubModule(subModuleStatement, subModuleStatement.NameToken.Text, Array.Empty(), body); if (subModules.ContainsKey(subModule.Name)) { @@ -49,12 +50,19 @@ public Binder(StatementBlockSyntax syntaxTree, DiagnosticBag diagnostics, bool i break; } - default: + case FunctionDeclarationSyntax functionDecl: { - var statement = this.BindStatementOpt(syntax); - if (!statement.IsDefault()) + var parameters = functionDecl.Parameters.Select(p => p.IdentifierToken.Text).ToList(); + var body = this.BindStatementBlock(functionDecl.Body); + var subModule = new BoundSubModule(functionDecl, functionDecl.NameToken.Text, parameters, body); + + if (subModules.ContainsKey(subModule.Name)) + { + this.diagnostics.ReportTwoSubModulesWithTheSameName(functionDecl.NameToken.Range, subModule.Name); + } + else { - mainModule.Add(statement); + subModules.Add(subModule.Name, subModule); } break; @@ -62,10 +70,23 @@ public Binder(StatementBlockSyntax syntaxTree, DiagnosticBag diagnostics, bool i } } + this.SubModules = subModules; + + // Second pass: bind main module statements + foreach (var syntax in syntaxTree.Body) + { + if (!(syntax is SubModuleStatementSyntax) && !(syntax is FunctionDeclarationSyntax)) + { + var statement = this.BindStatementOpt(syntax); + if (!statement.IsDefault()) + { + mainModule.Add(statement); + } + } + } + this.MainModule = new BoundStatementBlock(syntaxTree, mainModule); this.CheckForLabelErrors(this.MainModule); - - this.SubModules = subModules; foreach (var subModule in this.SubModules.Values) { this.CheckForLabelErrors(subModule.Body); @@ -90,8 +111,22 @@ private BaseBoundStatement BindStatementOpt(BaseStatementSyntax syntax) case IfStatementSyntax ifStatement: return this.BindIfStatement(ifStatement); case WhileStatementSyntax whileStatement: return this.BindWhileStatement(whileStatement); case ForStatementSyntax forStatement: return this.BindForStatement(forStatement); + case ForEachStatementSyntax forEachStatement: return this.BindForEachStatement(forEachStatement); + case SelectStatementSyntax selectStatement: return this.BindSelectStatement(selectStatement); + case TryStatementSyntax tryStatement: return this.BindTryStatement(tryStatement); case ExpressionStatementSyntax expressionStatement: return this.BindExpressionStatement(expressionStatement); + case ReturnStatementSyntax returnStatement: + { + BaseBoundExpression expr = null; + if (!returnStatement.ExpressionOpt.IsDefault()) + { + expr = this.BindExpression(returnStatement.ExpressionOpt); + } + + return new BoundReturnStatement(returnStatement, hasExpression: !expr.IsDefault(), expressionOpt: expr); + } + case LabelStatementSyntax labelStatement: return new BoundLabelStatement(labelStatement, labelStatement.LabelToken.Text); case GoToStatementSyntax goToStatement: return new BoundGoToStatement(goToStatement, goToStatement.LabelToken.Text); @@ -151,6 +186,54 @@ private BoundWhileStatement BindWhileStatement(WhileStatementSyntax syntax) return new BoundWhileStatement(syntax, expression, body); } + private BoundForEachStatement BindForEachStatement(ForEachStatementSyntax syntax) + { + string identifier = syntax.IdentifierToken.Text; + BaseBoundExpression collection = this.BindExpression(syntax.CollectionExpression); + BoundStatementBlock body = this.BindStatementBlock(syntax.Body); + return new BoundForEachStatement(syntax, identifier, collection, body); + } + + private BoundSelectStatement BindSelectStatement(SelectStatementSyntax syntax) + { + BaseBoundExpression expression = this.BindExpression(syntax.Expression); + var cases = new List(); + foreach (var clause in syntax.Cases) + { + BaseBoundExpression valExprOpt = null; + if (!clause.ValueExpressionOpt.IsDefault()) + { + valExprOpt = this.BindExpression(clause.ValueExpressionOpt); + } + + BoundStatementBlock body = this.BindStatementBlock(clause.Body); + cases.Add(new BoundCaseClause(clause, isElse: clause.CaseToken.Kind == TokenKind.Else, valueExpressionOpt: valExprOpt, body: body)); + } + + return new BoundSelectStatement(syntax, expression, cases); + } + + private BoundTryStatement BindTryStatement(TryStatementSyntax syntax) + { + BoundStatementBlock body = this.BindStatementBlock(syntax.Body); + BoundCatchClause catchClauseOpt = null; + if (!syntax.CatchClauseOpt.IsDefault()) + { + string varName = syntax.CatchClauseOpt.VariableTokenOpt.IsDefault() ? null : syntax.CatchClauseOpt.VariableTokenOpt.Text; + BoundStatementBlock catchBody = this.BindStatementBlock(syntax.CatchClauseOpt.Body); + catchClauseOpt = new BoundCatchClause(syntax.CatchClauseOpt, varName, catchBody); + } + + BoundFinallyClause finallyClauseOpt = null; + if (!syntax.FinallyClauseOpt.IsDefault()) + { + BoundStatementBlock finallyBody = this.BindStatementBlock(syntax.FinallyClauseOpt.Body); + finallyClauseOpt = new BoundFinallyClause(syntax.FinallyClauseOpt, finallyBody); + } + + return new BoundTryStatement(syntax, body, catchClauseOpt, finallyClauseOpt); + } + private BoundForStatement BindForStatement(ForStatementSyntax syntax) { string identifier = syntax.IdentifierToken.Text; @@ -245,6 +328,13 @@ private BaseBoundStatement BindAssignmentExpressionStatement(ExpressionStatement } } + case BoundSubModuleInvocationExpression subModuleInvocation: + case BoundSubModuleExpression subModule: + { + this.diagnostics.ReportUnassignedExpressionStatement(syntax.Range); + return new BoundInvalidExpressionStatement(syntax, assignment); + } + default: { this.diagnostics.ReportUnassignedExpressionStatement(syntax.Range); @@ -502,21 +592,29 @@ private BaseBoundExpression BindInvocationExpression(InvocationExpressionSyntax case BoundSubModuleExpression subModule: { + int expectedParams = 0; + bool isFunction = false; + if (!this.SubModules.IsDefault() && this.SubModules.TryGetValue(subModule.Name, out var subModuleNode)) + { + expectedParams = subModuleNode.Parameters.Count; + isFunction = subModuleNode.Syntax is FunctionDeclarationSyntax; + } + if (!hasErrors) { - if (arguments.Count != 0) + if (arguments.Count != expectedParams) { hasErrors = true; - this.diagnostics.ReportUnexpectedArgumentsCount(syntax.Range, arguments.Count, 0); + this.diagnostics.ReportUnexpectedArgumentsCount(syntax.Range, arguments.Count, expectedParams); } - else if (expectsValue) + else if (expectsValue && !isFunction) { hasErrors = true; this.diagnostics.ReportExpectedExpressionWithAValue(syntax.Range); } } - return new BoundSubModuleInvocationExpression(syntax, hasValue: false, hasErrors, subModule.Name); + return new BoundSubModuleInvocationExpression(syntax, hasValue: isFunction, hasErrors: hasErrors, name: subModule.Name, arguments: arguments); } default: @@ -542,14 +640,9 @@ private BaseBoundExpression BindIdentifierExpression(IdentifierExpressionSyntax return new BoundLibraryTypeExpression(syntax, hasValue: false, hasErrors, name); } - else if (this.definedSubModules.Contains(name)) + else if (!expectsValue && this.definedSubModules.Contains(name)) { - if (expectsValue) - { - return new BoundVariableExpression(syntax, hasValue: true, hasErrors, name); - } - - return new BoundSubModuleExpression(syntax, hasValue: false, hasErrors, name); + return new BoundSubModuleExpression(syntax, hasValue: false, hasErrors: hasErrors, name: name); } else { diff --git a/Source/SmallBasic.Compiler/Binding/BoundNodes.Generated.cs b/Source/SmallBasic.Compiler/Binding/BoundNodes.Generated.cs index 24b761cf..90319a80 100644 --- a/Source/SmallBasic.Compiler/Binding/BoundNodes.Generated.cs +++ b/Source/SmallBasic.Compiler/Binding/BoundNodes.Generated.cs @@ -1,1210 +1,1498 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Compiler.Binding -{ - using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; - using SmallBasic.Compiler.Parsing; - using SmallBasic.Compiler.Scanning; - using SmallBasic.Utilities; - - public abstract class BaseBoundNodeVisitor - { - private protected void Visit(BaseBoundNode node) - { - switch (node) - { - case BoundSubModule subModule: - this.VisitSubModule(subModule); - break; - case BoundStatementBlock statementBlock: - this.VisitStatementBlock(statementBlock); - break; - case BoundIfPart ifPart: - this.VisitIfPart(ifPart); - break; - case BoundElseIfPart elseIfPart: - this.VisitElseIfPart(elseIfPart); - break; - case BoundElsePart elsePart: - this.VisitElsePart(elsePart); - break; - case BoundIfStatement ifStatement: - this.VisitIfStatement(ifStatement); - break; - case BoundWhileStatement whileStatement: - this.VisitWhileStatement(whileStatement); - break; - case BoundForStatement forStatement: - this.VisitForStatement(forStatement); - break; - case BoundLabelStatement labelStatement: - this.VisitLabelStatement(labelStatement); - break; - case BoundGoToStatement goToStatement: - this.VisitGoToStatement(goToStatement); - break; - case BoundSubModuleInvocationStatement subModuleInvocationStatement: - this.VisitSubModuleInvocationStatement(subModuleInvocationStatement); - break; - case BoundLibraryMethodInvocationStatement libraryMethodInvocationStatement: - this.VisitLibraryMethodInvocationStatement(libraryMethodInvocationStatement); - break; - case BoundVariableAssignmentStatement variableAssignmentStatement: - this.VisitVariableAssignmentStatement(variableAssignmentStatement); - break; - case BoundPropertyAssignmentStatement propertyAssignmentStatement: - this.VisitPropertyAssignmentStatement(propertyAssignmentStatement); - break; - case BoundEventAssignmentStatement eventAssignmentStatement: - this.VisitEventAssignmentStatement(eventAssignmentStatement); - break; - case BoundArrayAssignmentStatement arrayAssignmentStatement: - this.VisitArrayAssignmentStatement(arrayAssignmentStatement); - break; - case BoundInvalidExpressionStatement invalidExpressionStatement: - this.VisitInvalidExpressionStatement(invalidExpressionStatement); - break; - case BoundUnaryExpression unaryExpression: - this.VisitUnaryExpression(unaryExpression); - break; - case BoundBinaryExpression binaryExpression: - this.VisitBinaryExpression(binaryExpression); - break; - case BoundArrayAccessExpression arrayAccessExpression: - this.VisitArrayAccessExpression(arrayAccessExpression); - break; - case BoundLibraryTypeExpression libraryTypeExpression: - this.VisitLibraryTypeExpression(libraryTypeExpression); - break; - case BoundLibraryMethodExpression libraryMethodExpression: - this.VisitLibraryMethodExpression(libraryMethodExpression); - break; - case BoundLibraryPropertyExpression libraryPropertyExpression: - this.VisitLibraryPropertyExpression(libraryPropertyExpression); - break; - case BoundLibraryEventExpression libraryEventExpression: - this.VisitLibraryEventExpression(libraryEventExpression); - break; - case BoundLibraryMethodInvocationExpression libraryMethodInvocationExpression: - this.VisitLibraryMethodInvocationExpression(libraryMethodInvocationExpression); - break; - case BoundSubModuleExpression subModuleExpression: - this.VisitSubModuleExpression(subModuleExpression); - break; - case BoundSubModuleInvocationExpression subModuleInvocationExpression: - this.VisitSubModuleInvocationExpression(subModuleInvocationExpression); - break; - case BoundVariableExpression variableExpression: - this.VisitVariableExpression(variableExpression); - break; - case BoundStringLiteralExpression stringLiteralExpression: - this.VisitStringLiteralExpression(stringLiteralExpression); - break; - case BoundNumberLiteralExpression numberLiteralExpression: - this.VisitNumberLiteralExpression(numberLiteralExpression); - break; - case BoundParenthesisExpression parenthesisExpression: - this.VisitParenthesisExpression(parenthesisExpression); - break; - case BoundInvalidExpression invalidExpression: - this.VisitInvalidExpression(invalidExpression); - break; - default: - throw ExceptionUtilities.UnexpectedValue(node); - } - } - - private protected virtual void VisitSubModule(BoundSubModule node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitStatementBlock(BoundStatementBlock node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitIfPart(BoundIfPart node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitElseIfPart(BoundElseIfPart node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitElsePart(BoundElsePart node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitIfStatement(BoundIfStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitWhileStatement(BoundWhileStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitForStatement(BoundForStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitLabelStatement(BoundLabelStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitGoToStatement(BoundGoToStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitSubModuleInvocationStatement(BoundSubModuleInvocationStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitLibraryMethodInvocationStatement(BoundLibraryMethodInvocationStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitVariableAssignmentStatement(BoundVariableAssignmentStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitPropertyAssignmentStatement(BoundPropertyAssignmentStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitEventAssignmentStatement(BoundEventAssignmentStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitArrayAssignmentStatement(BoundArrayAssignmentStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitInvalidExpressionStatement(BoundInvalidExpressionStatement node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitUnaryExpression(BoundUnaryExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitBinaryExpression(BoundBinaryExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitArrayAccessExpression(BoundArrayAccessExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitLibraryTypeExpression(BoundLibraryTypeExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitLibraryMethodExpression(BoundLibraryMethodExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitLibraryPropertyExpression(BoundLibraryPropertyExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitLibraryEventExpression(BoundLibraryEventExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitLibraryMethodInvocationExpression(BoundLibraryMethodInvocationExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitSubModuleExpression(BoundSubModuleExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitSubModuleInvocationExpression(BoundSubModuleInvocationExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitVariableExpression(BoundVariableExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitStringLiteralExpression(BoundStringLiteralExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitNumberLiteralExpression(BoundNumberLiteralExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitParenthesisExpression(BoundParenthesisExpression node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitInvalidExpression(BoundInvalidExpression node) - { - this.DefaultVisit(node); - } - - private void DefaultVisit(BaseBoundNode node) - { - foreach (var child in node.Children) - { - this.Visit(child); - } - } - } - - internal sealed class BoundSubModule : BaseBoundNode - { - public BoundSubModule(SubModuleStatementSyntax syntax, string name, BoundStatementBlock body) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!name.IsDefault(), "'name' must not be null."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.Syntax = syntax; - this.Name = name; - this.Body = body; - } - - public SubModuleStatementSyntax Syntax { get; private set; } - - public string Name { get; private set; } - - public BoundStatementBlock Body { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Body; - } - } - } - - internal abstract class BaseBoundStatement : BaseBoundNode - { - } - - internal sealed class BoundStatementBlock : BaseBoundStatement - { - public BoundStatementBlock(StatementBlockSyntax syntax, IReadOnlyList body) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.Syntax = syntax; - this.Body = body; - } - - public StatementBlockSyntax Syntax { get; private set; } - - public IReadOnlyList Body { get; private set; } - - public override IEnumerable Children - { - get - { - foreach (var child in this.Body) - { - yield return child; - } - } - } - } - - internal sealed class BoundIfPart : BaseBoundNode - { - public BoundIfPart(IfPartSyntax syntax, BaseBoundExpression condition, BoundStatementBlock body) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.Syntax = syntax; - this.Condition = condition; - this.Body = body; - } - - public IfPartSyntax Syntax { get; private set; } - - public BaseBoundExpression Condition { get; private set; } - - public BoundStatementBlock Body { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Condition; - yield return this.Body; - } - } - } - - internal sealed class BoundElseIfPart : BaseBoundNode - { - public BoundElseIfPart(ElseIfPartSyntax syntax, BaseBoundExpression condition, BoundStatementBlock body) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.Syntax = syntax; - this.Condition = condition; - this.Body = body; - } - - public ElseIfPartSyntax Syntax { get; private set; } - - public BaseBoundExpression Condition { get; private set; } - - public BoundStatementBlock Body { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Condition; - yield return this.Body; - } - } - } - - internal sealed class BoundElsePart : BaseBoundNode - { - public BoundElsePart(ElsePartSyntax syntax, BoundStatementBlock body) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.Syntax = syntax; - this.Body = body; - } - - public ElsePartSyntax Syntax { get; private set; } - - public BoundStatementBlock Body { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Body; - } - } - } - - internal sealed class BoundIfStatement : BaseBoundStatement - { - public BoundIfStatement(IfStatementSyntax syntax, BoundIfPart ifPart, IReadOnlyList elseIfParts, BoundElsePart elsePartOpt) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!ifPart.IsDefault(), "'ifPart' must not be null."); - Debug.Assert(!elseIfParts.IsDefault(), "'elseIfParts' must not be null."); - - this.Syntax = syntax; - this.IfPart = ifPart; - this.ElseIfParts = elseIfParts; - this.ElsePartOpt = elsePartOpt; - } - - public IfStatementSyntax Syntax { get; private set; } - - public BoundIfPart IfPart { get; private set; } - - public IReadOnlyList ElseIfParts { get; private set; } - - public BoundElsePart ElsePartOpt { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.IfPart; - foreach (var child in this.ElseIfParts) - { - yield return child; - } - - if (!this.ElsePartOpt.IsDefault()) - { - yield return this.ElsePartOpt; - } - } - } - } - - internal sealed class BoundWhileStatement : BaseBoundStatement - { - public BoundWhileStatement(WhileStatementSyntax syntax, BaseBoundExpression condition, BoundStatementBlock body) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.Syntax = syntax; - this.Condition = condition; - this.Body = body; - } - - public WhileStatementSyntax Syntax { get; private set; } - - public BaseBoundExpression Condition { get; private set; } - - public BoundStatementBlock Body { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Condition; - yield return this.Body; - } - } - } - - internal sealed class BoundForStatement : BaseBoundStatement - { - public BoundForStatement(ForStatementSyntax syntax, string identifier, BaseBoundExpression fromExpression, BaseBoundExpression toExpression, BaseBoundExpression stepExpressionOpt, BoundStatementBlock body) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!identifier.IsDefault(), "'identifier' must not be null."); - Debug.Assert(!fromExpression.IsDefault(), "'fromExpression' must not be null."); - Debug.Assert(!toExpression.IsDefault(), "'toExpression' must not be null."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.Syntax = syntax; - this.Identifier = identifier; - this.FromExpression = fromExpression; - this.ToExpression = toExpression; - this.StepExpressionOpt = stepExpressionOpt; - this.Body = body; - } - - public ForStatementSyntax Syntax { get; private set; } - - public string Identifier { get; private set; } - - public BaseBoundExpression FromExpression { get; private set; } - - public BaseBoundExpression ToExpression { get; private set; } - - public BaseBoundExpression StepExpressionOpt { get; private set; } - - public BoundStatementBlock Body { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.FromExpression; - yield return this.ToExpression; - if (!this.StepExpressionOpt.IsDefault()) - { - yield return this.StepExpressionOpt; - } - - yield return this.Body; - } - } - } - - internal sealed class BoundLabelStatement : BaseBoundStatement - { - public BoundLabelStatement(LabelStatementSyntax syntax, string label) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!label.IsDefault(), "'label' must not be null."); - - this.Syntax = syntax; - this.Label = label; - } - - public LabelStatementSyntax Syntax { get; private set; } - - public string Label { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - } - - internal sealed class BoundGoToStatement : BaseBoundStatement - { - public BoundGoToStatement(GoToStatementSyntax syntax, string label) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!label.IsDefault(), "'label' must not be null."); - - this.Syntax = syntax; - this.Label = label; - } - - public GoToStatementSyntax Syntax { get; private set; } - - public string Label { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - } - - internal sealed class BoundSubModuleInvocationStatement : BaseBoundStatement - { - public BoundSubModuleInvocationStatement(ExpressionStatementSyntax syntax, BoundSubModuleInvocationExpression expression) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.Syntax = syntax; - this.Expression = expression; - } - - public ExpressionStatementSyntax Syntax { get; private set; } - - public BoundSubModuleInvocationExpression Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - } - - internal sealed class BoundLibraryMethodInvocationStatement : BaseBoundStatement - { - public BoundLibraryMethodInvocationStatement(ExpressionStatementSyntax syntax, BoundLibraryMethodInvocationExpression expression) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.Syntax = syntax; - this.Expression = expression; - } - - public ExpressionStatementSyntax Syntax { get; private set; } - - public BoundLibraryMethodInvocationExpression Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - } - - internal sealed class BoundVariableAssignmentStatement : BaseBoundStatement - { - public BoundVariableAssignmentStatement(ExpressionStatementSyntax syntax, BoundVariableExpression variable, BaseBoundExpression expression) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!variable.IsDefault(), "'variable' must not be null."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.Syntax = syntax; - this.Variable = variable; - this.Expression = expression; - } - - public ExpressionStatementSyntax Syntax { get; private set; } - - public BoundVariableExpression Variable { get; private set; } - - public BaseBoundExpression Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Variable; - yield return this.Expression; - } - } - } - - internal sealed class BoundPropertyAssignmentStatement : BaseBoundStatement - { - public BoundPropertyAssignmentStatement(ExpressionStatementSyntax syntax, BoundLibraryPropertyExpression property, BaseBoundExpression expression) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!property.IsDefault(), "'property' must not be null."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.Syntax = syntax; - this.Property = property; - this.Expression = expression; - } - - public ExpressionStatementSyntax Syntax { get; private set; } - - public BoundLibraryPropertyExpression Property { get; private set; } - - public BaseBoundExpression Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Property; - yield return this.Expression; - } - } - } - - internal sealed class BoundEventAssignmentStatement : BaseBoundStatement - { - public BoundEventAssignmentStatement(ExpressionStatementSyntax syntax, BoundLibraryEventExpression usedEvent, string subModule) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!usedEvent.IsDefault(), "'usedEvent' must not be null."); - Debug.Assert(!subModule.IsDefault(), "'subModule' must not be null."); - - this.Syntax = syntax; - this.UsedEvent = usedEvent; - this.SubModule = subModule; - } - - public ExpressionStatementSyntax Syntax { get; private set; } - - public BoundLibraryEventExpression UsedEvent { get; private set; } - - public string SubModule { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.UsedEvent; - } - } - } - - internal sealed class BoundArrayAssignmentStatement : BaseBoundStatement - { - public BoundArrayAssignmentStatement(ExpressionStatementSyntax syntax, BoundArrayAccessExpression array, BaseBoundExpression expression) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!array.IsDefault(), "'array' must not be null."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.Syntax = syntax; - this.Array = array; - this.Expression = expression; - } - - public ExpressionStatementSyntax Syntax { get; private set; } - - public BoundArrayAccessExpression Array { get; private set; } - - public BaseBoundExpression Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Array; - yield return this.Expression; - } - } - } - - internal sealed class BoundInvalidExpressionStatement : BaseBoundStatement - { - public BoundInvalidExpressionStatement(ExpressionStatementSyntax syntax, BaseBoundExpression expression) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.Syntax = syntax; - this.Expression = expression; - } - - public ExpressionStatementSyntax Syntax { get; private set; } - - public BaseBoundExpression Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - } - - internal abstract class BaseBoundExpression : BaseBoundNode - { - public BaseBoundExpression(bool hasValue, bool hasErrors) - { - Debug.Assert(!hasValue.IsDefault(), "'hasValue' must not be null."); - Debug.Assert(!hasErrors.IsDefault(), "'hasErrors' must not be null."); - - this.HasValue = hasValue; - this.HasErrors = hasErrors; - } - - public bool HasValue { get; private set; } - - public bool HasErrors { get; private set; } - } - - internal sealed class BoundUnaryExpression : BaseBoundExpression - { - public BoundUnaryExpression(UnaryOperatorExpressionSyntax syntax, bool hasValue, bool hasErrors, TokenKind kind, BaseBoundExpression expression) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!kind.IsDefault(), "'kind' must not be null."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.Syntax = syntax; - this.Kind = kind; - this.Expression = expression; - } - - public UnaryOperatorExpressionSyntax Syntax { get; private set; } - - public TokenKind Kind { get; private set; } - - public BaseBoundExpression Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - } - - internal sealed class BoundBinaryExpression : BaseBoundExpression - { - public BoundBinaryExpression(BinaryOperatorExpressionSyntax syntax, bool hasValue, bool hasErrors, TokenKind kind, BaseBoundExpression left, BaseBoundExpression right) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!kind.IsDefault(), "'kind' must not be null."); - Debug.Assert(!left.IsDefault(), "'left' must not be null."); - Debug.Assert(!right.IsDefault(), "'right' must not be null."); - - this.Syntax = syntax; - this.Kind = kind; - this.Left = left; - this.Right = right; - } - - public BinaryOperatorExpressionSyntax Syntax { get; private set; } - - public TokenKind Kind { get; private set; } - - public BaseBoundExpression Left { get; private set; } - - public BaseBoundExpression Right { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Left; - yield return this.Right; - } - } - } - - internal sealed class BoundArrayAccessExpression : BaseBoundExpression - { - public BoundArrayAccessExpression(ArrayAccessExpressionSyntax syntax, bool hasValue, bool hasErrors, string name, IReadOnlyList indices) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!name.IsDefault(), "'name' must not be null."); - Debug.Assert(!indices.IsDefault(), "'indices' must not be null."); - - this.Syntax = syntax; - this.Name = name; - this.Indices = indices; - } - - public ArrayAccessExpressionSyntax Syntax { get; private set; } - - public string Name { get; private set; } - - public IReadOnlyList Indices { get; private set; } - - public override IEnumerable Children - { - get - { - foreach (var child in this.Indices) - { - yield return child; - } - } - } - } - - internal sealed class BoundLibraryTypeExpression : BaseBoundExpression - { - public BoundLibraryTypeExpression(IdentifierExpressionSyntax syntax, bool hasValue, bool hasErrors, string name) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!name.IsDefault(), "'name' must not be null."); - - this.Syntax = syntax; - this.Name = name; - } - - public IdentifierExpressionSyntax Syntax { get; private set; } - - public string Name { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - } - - internal sealed class BoundLibraryMethodExpression : BaseBoundExpression - { - public BoundLibraryMethodExpression(ObjectAccessExpressionSyntax syntax, bool hasValue, bool hasErrors, BoundLibraryTypeExpression library, string name) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!library.IsDefault(), "'library' must not be null."); - Debug.Assert(!name.IsDefault(), "'name' must not be null."); - - this.Syntax = syntax; - this.Library = library; - this.Name = name; - } - - public ObjectAccessExpressionSyntax Syntax { get; private set; } - - public BoundLibraryTypeExpression Library { get; private set; } - - public string Name { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Library; - } - } - } - - internal sealed class BoundLibraryPropertyExpression : BaseBoundExpression - { - public BoundLibraryPropertyExpression(ObjectAccessExpressionSyntax syntax, bool hasValue, bool hasErrors, BoundLibraryTypeExpression library, string name) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!library.IsDefault(), "'library' must not be null."); - Debug.Assert(!name.IsDefault(), "'name' must not be null."); - - this.Syntax = syntax; - this.Library = library; - this.Name = name; - } - - public ObjectAccessExpressionSyntax Syntax { get; private set; } - - public BoundLibraryTypeExpression Library { get; private set; } - - public string Name { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Library; - } - } - } - - internal sealed class BoundLibraryEventExpression : BaseBoundExpression - { - public BoundLibraryEventExpression(ObjectAccessExpressionSyntax syntax, bool hasValue, bool hasErrors, BoundLibraryTypeExpression library, string name) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!library.IsDefault(), "'library' must not be null."); - Debug.Assert(!name.IsDefault(), "'name' must not be null."); - - this.Syntax = syntax; - this.Library = library; - this.Name = name; - } - - public ObjectAccessExpressionSyntax Syntax { get; private set; } - - public BoundLibraryTypeExpression Library { get; private set; } - - public string Name { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Library; - } - } - } - - internal sealed class BoundLibraryMethodInvocationExpression : BaseBoundExpression - { - public BoundLibraryMethodInvocationExpression(InvocationExpressionSyntax syntax, bool hasValue, bool hasErrors, BoundLibraryMethodExpression method, IReadOnlyList arguments) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!method.IsDefault(), "'method' must not be null."); - Debug.Assert(!arguments.IsDefault(), "'arguments' must not be null."); - - this.Syntax = syntax; - this.Method = method; - this.Arguments = arguments; - } - - public InvocationExpressionSyntax Syntax { get; private set; } - - public BoundLibraryMethodExpression Method { get; private set; } - - public IReadOnlyList Arguments { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Method; - foreach (var child in this.Arguments) - { - yield return child; - } - } - } - } - - internal sealed class BoundSubModuleExpression : BaseBoundExpression - { - public BoundSubModuleExpression(IdentifierExpressionSyntax syntax, bool hasValue, bool hasErrors, string name) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!name.IsDefault(), "'name' must not be null."); - - this.Syntax = syntax; - this.Name = name; - } - - public IdentifierExpressionSyntax Syntax { get; private set; } - - public string Name { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - } - - internal sealed class BoundSubModuleInvocationExpression : BaseBoundExpression - { - public BoundSubModuleInvocationExpression(InvocationExpressionSyntax syntax, bool hasValue, bool hasErrors, string name) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!name.IsDefault(), "'name' must not be null."); - - this.Syntax = syntax; - this.Name = name; - } - - public InvocationExpressionSyntax Syntax { get; private set; } - - public string Name { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - } - - internal sealed class BoundVariableExpression : BaseBoundExpression - { - public BoundVariableExpression(IdentifierExpressionSyntax syntax, bool hasValue, bool hasErrors, string name) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!name.IsDefault(), "'name' must not be null."); - - this.Syntax = syntax; - this.Name = name; - } - - public IdentifierExpressionSyntax Syntax { get; private set; } - - public string Name { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - } - - internal sealed class BoundStringLiteralExpression : BaseBoundExpression - { - public BoundStringLiteralExpression(StringLiteralExpressionSyntax syntax, bool hasValue, bool hasErrors, string value) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!value.IsDefault(), "'value' must not be null."); - - this.Syntax = syntax; - this.Value = value; - } - - public StringLiteralExpressionSyntax Syntax { get; private set; } - - public string Value { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - } - - internal sealed class BoundNumberLiteralExpression : BaseBoundExpression - { - public BoundNumberLiteralExpression(NumberLiteralExpressionSyntax syntax, bool hasValue, bool hasErrors, decimal value) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!value.IsDefault(), "'value' must not be null."); - - this.Syntax = syntax; - this.Value = value; - } - - public NumberLiteralExpressionSyntax Syntax { get; private set; } - - public decimal Value { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - } - - internal sealed class BoundParenthesisExpression : BaseBoundExpression - { - public BoundParenthesisExpression(ParenthesisExpressionSyntax syntax, bool hasValue, bool hasErrors, BaseBoundExpression expression) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.Syntax = syntax; - this.Expression = expression; - } - - public ParenthesisExpressionSyntax Syntax { get; private set; } - - public BaseBoundExpression Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - } - - internal sealed class BoundInvalidExpression : BaseBoundExpression - { - public BoundInvalidExpression(BaseExpressionSyntax syntax, bool hasValue, bool hasErrors) - : base(hasValue, hasErrors) - { - Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); - - this.Syntax = syntax; - } - - public BaseExpressionSyntax Syntax { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Compiler.Binding +{ + using System.Collections.Generic; + using System.Diagnostics; + using System.Linq; + using SmallBasic.Compiler.Parsing; + using SmallBasic.Compiler.Scanning; + using SmallBasic.Utilities; + + public abstract class BaseBoundNodeVisitor + { + private protected void Visit(BaseBoundNode node) + { + switch (node) + { + case BoundSubModule subModule: + this.VisitSubModule(subModule); + break; + case BoundReturnStatement returnStatement: + this.VisitReturnStatement(returnStatement); + break; + case BoundStatementBlock statementBlock: + this.VisitStatementBlock(statementBlock); + break; + case BoundIfPart ifPart: + this.VisitIfPart(ifPart); + break; + case BoundElseIfPart elseIfPart: + this.VisitElseIfPart(elseIfPart); + break; + case BoundElsePart elsePart: + this.VisitElsePart(elsePart); + break; + case BoundIfStatement ifStatement: + this.VisitIfStatement(ifStatement); + break; + case BoundWhileStatement whileStatement: + this.VisitWhileStatement(whileStatement); + break; + case BoundForStatement forStatement: + this.VisitForStatement(forStatement); + break; + case BoundForEachStatement forEachStatement: + this.VisitForEachStatement(forEachStatement); + break; + case BoundCaseClause caseClause: + this.VisitCaseClause(caseClause); + break; + case BoundSelectStatement selectStatement: + this.VisitSelectStatement(selectStatement); + break; + case BoundCatchClause catchClause: + this.VisitCatchClause(catchClause); + break; + case BoundFinallyClause finallyClause: + this.VisitFinallyClause(finallyClause); + break; + case BoundTryStatement tryStatement: + this.VisitTryStatement(tryStatement); + break; + case BoundLabelStatement labelStatement: + this.VisitLabelStatement(labelStatement); + break; + case BoundGoToStatement goToStatement: + this.VisitGoToStatement(goToStatement); + break; + case BoundSubModuleInvocationStatement subModuleInvocationStatement: + this.VisitSubModuleInvocationStatement(subModuleInvocationStatement); + break; + case BoundLibraryMethodInvocationStatement libraryMethodInvocationStatement: + this.VisitLibraryMethodInvocationStatement(libraryMethodInvocationStatement); + break; + case BoundVariableAssignmentStatement variableAssignmentStatement: + this.VisitVariableAssignmentStatement(variableAssignmentStatement); + break; + case BoundPropertyAssignmentStatement propertyAssignmentStatement: + this.VisitPropertyAssignmentStatement(propertyAssignmentStatement); + break; + case BoundEventAssignmentStatement eventAssignmentStatement: + this.VisitEventAssignmentStatement(eventAssignmentStatement); + break; + case BoundArrayAssignmentStatement arrayAssignmentStatement: + this.VisitArrayAssignmentStatement(arrayAssignmentStatement); + break; + case BoundInvalidExpressionStatement invalidExpressionStatement: + this.VisitInvalidExpressionStatement(invalidExpressionStatement); + break; + case BoundUnaryExpression unaryExpression: + this.VisitUnaryExpression(unaryExpression); + break; + case BoundBinaryExpression binaryExpression: + this.VisitBinaryExpression(binaryExpression); + break; + case BoundArrayAccessExpression arrayAccessExpression: + this.VisitArrayAccessExpression(arrayAccessExpression); + break; + case BoundLibraryTypeExpression libraryTypeExpression: + this.VisitLibraryTypeExpression(libraryTypeExpression); + break; + case BoundLibraryMethodExpression libraryMethodExpression: + this.VisitLibraryMethodExpression(libraryMethodExpression); + break; + case BoundLibraryPropertyExpression libraryPropertyExpression: + this.VisitLibraryPropertyExpression(libraryPropertyExpression); + break; + case BoundLibraryEventExpression libraryEventExpression: + this.VisitLibraryEventExpression(libraryEventExpression); + break; + case BoundLibraryMethodInvocationExpression libraryMethodInvocationExpression: + this.VisitLibraryMethodInvocationExpression(libraryMethodInvocationExpression); + break; + case BoundSubModuleExpression subModuleExpression: + this.VisitSubModuleExpression(subModuleExpression); + break; + case BoundSubModuleInvocationExpression subModuleInvocationExpression: + this.VisitSubModuleInvocationExpression(subModuleInvocationExpression); + break; + case BoundVariableExpression variableExpression: + this.VisitVariableExpression(variableExpression); + break; + case BoundStringLiteralExpression stringLiteralExpression: + this.VisitStringLiteralExpression(stringLiteralExpression); + break; + case BoundNumberLiteralExpression numberLiteralExpression: + this.VisitNumberLiteralExpression(numberLiteralExpression); + break; + case BoundParenthesisExpression parenthesisExpression: + this.VisitParenthesisExpression(parenthesisExpression); + break; + case BoundInvalidExpression invalidExpression: + this.VisitInvalidExpression(invalidExpression); + break; + default: + throw ExceptionUtilities.UnexpectedValue(node); + } + } + + private protected virtual void VisitSubModule(BoundSubModule node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitReturnStatement(BoundReturnStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitStatementBlock(BoundStatementBlock node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitIfPart(BoundIfPart node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitElseIfPart(BoundElseIfPart node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitElsePart(BoundElsePart node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitIfStatement(BoundIfStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitWhileStatement(BoundWhileStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitForStatement(BoundForStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitForEachStatement(BoundForEachStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitCaseClause(BoundCaseClause node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitSelectStatement(BoundSelectStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitCatchClause(BoundCatchClause node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitFinallyClause(BoundFinallyClause node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitTryStatement(BoundTryStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitLabelStatement(BoundLabelStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitGoToStatement(BoundGoToStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitSubModuleInvocationStatement(BoundSubModuleInvocationStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitLibraryMethodInvocationStatement(BoundLibraryMethodInvocationStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitVariableAssignmentStatement(BoundVariableAssignmentStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitPropertyAssignmentStatement(BoundPropertyAssignmentStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitEventAssignmentStatement(BoundEventAssignmentStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitArrayAssignmentStatement(BoundArrayAssignmentStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitInvalidExpressionStatement(BoundInvalidExpressionStatement node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitUnaryExpression(BoundUnaryExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitBinaryExpression(BoundBinaryExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitArrayAccessExpression(BoundArrayAccessExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitLibraryTypeExpression(BoundLibraryTypeExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitLibraryMethodExpression(BoundLibraryMethodExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitLibraryPropertyExpression(BoundLibraryPropertyExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitLibraryEventExpression(BoundLibraryEventExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitLibraryMethodInvocationExpression(BoundLibraryMethodInvocationExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitSubModuleExpression(BoundSubModuleExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitSubModuleInvocationExpression(BoundSubModuleInvocationExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitVariableExpression(BoundVariableExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitStringLiteralExpression(BoundStringLiteralExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitNumberLiteralExpression(BoundNumberLiteralExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitParenthesisExpression(BoundParenthesisExpression node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitInvalidExpression(BoundInvalidExpression node) + { + this.DefaultVisit(node); + } + + private void DefaultVisit(BaseBoundNode node) + { + foreach (var child in node.Children) + { + this.Visit(child); + } + } + } + + internal sealed class BoundSubModule : BaseBoundNode + { + public BoundSubModule(BaseStatementSyntax syntax, string name, IReadOnlyList parameters, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!name.IsDefault(), "'name' must not be null."); + Debug.Assert(!parameters.IsDefault(), "'parameters' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Name = name; + this.Parameters = parameters; + this.Body = body; + } + + public BaseStatementSyntax Syntax { get; private set; } + + public string Name { get; private set; } + + public IReadOnlyList Parameters { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + } + } + } + + internal sealed class BoundReturnStatement : BaseBoundStatement + { + public BoundReturnStatement(ReturnStatementSyntax syntax, bool hasExpression, BaseBoundExpression expressionOpt) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!hasExpression.IsDefault(), "'hasExpression' must not be null."); + + this.Syntax = syntax; + this.HasExpression = hasExpression; + this.ExpressionOpt = expressionOpt; + } + + public ReturnStatementSyntax Syntax { get; private set; } + + public bool HasExpression { get; private set; } + + public BaseBoundExpression ExpressionOpt { get; private set; } + + public override IEnumerable Children + { + get + { + if (!this.ExpressionOpt.IsDefault()) + { + yield return this.ExpressionOpt; + } + } + } + } + + internal abstract class BaseBoundStatement : BaseBoundNode + { + } + + internal sealed class BoundStatementBlock : BaseBoundStatement + { + public BoundStatementBlock(StatementBlockSyntax syntax, IReadOnlyList body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Body = body; + } + + public StatementBlockSyntax Syntax { get; private set; } + + public IReadOnlyList Body { get; private set; } + + public override IEnumerable Children + { + get + { + foreach (var child in this.Body) + { + yield return child; + } + } + } + } + + internal sealed class BoundIfPart : BaseBoundNode + { + public BoundIfPart(IfPartSyntax syntax, BaseBoundExpression condition, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Condition = condition; + this.Body = body; + } + + public IfPartSyntax Syntax { get; private set; } + + public BaseBoundExpression Condition { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Condition; + yield return this.Body; + } + } + } + + internal sealed class BoundElseIfPart : BaseBoundNode + { + public BoundElseIfPart(ElseIfPartSyntax syntax, BaseBoundExpression condition, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Condition = condition; + this.Body = body; + } + + public ElseIfPartSyntax Syntax { get; private set; } + + public BaseBoundExpression Condition { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Condition; + yield return this.Body; + } + } + } + + internal sealed class BoundElsePart : BaseBoundNode + { + public BoundElsePart(ElsePartSyntax syntax, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Body = body; + } + + public ElsePartSyntax Syntax { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + } + } + } + + internal sealed class BoundIfStatement : BaseBoundStatement + { + public BoundIfStatement(IfStatementSyntax syntax, BoundIfPart ifPart, IReadOnlyList elseIfParts, BoundElsePart elsePartOpt) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!ifPart.IsDefault(), "'ifPart' must not be null."); + Debug.Assert(!elseIfParts.IsDefault(), "'elseIfParts' must not be null."); + + this.Syntax = syntax; + this.IfPart = ifPart; + this.ElseIfParts = elseIfParts; + this.ElsePartOpt = elsePartOpt; + } + + public IfStatementSyntax Syntax { get; private set; } + + public BoundIfPart IfPart { get; private set; } + + public IReadOnlyList ElseIfParts { get; private set; } + + public BoundElsePart ElsePartOpt { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.IfPart; + foreach (var child in this.ElseIfParts) + { + yield return child; + } + + if (!this.ElsePartOpt.IsDefault()) + { + yield return this.ElsePartOpt; + } + } + } + } + + internal sealed class BoundWhileStatement : BaseBoundStatement + { + public BoundWhileStatement(WhileStatementSyntax syntax, BaseBoundExpression condition, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Condition = condition; + this.Body = body; + } + + public WhileStatementSyntax Syntax { get; private set; } + + public BaseBoundExpression Condition { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Condition; + yield return this.Body; + } + } + } + + internal sealed class BoundForStatement : BaseBoundStatement + { + public BoundForStatement(ForStatementSyntax syntax, string identifier, BaseBoundExpression fromExpression, BaseBoundExpression toExpression, BaseBoundExpression stepExpressionOpt, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!identifier.IsDefault(), "'identifier' must not be null."); + Debug.Assert(!fromExpression.IsDefault(), "'fromExpression' must not be null."); + Debug.Assert(!toExpression.IsDefault(), "'toExpression' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Identifier = identifier; + this.FromExpression = fromExpression; + this.ToExpression = toExpression; + this.StepExpressionOpt = stepExpressionOpt; + this.Body = body; + } + + public ForStatementSyntax Syntax { get; private set; } + + public string Identifier { get; private set; } + + public BaseBoundExpression FromExpression { get; private set; } + + public BaseBoundExpression ToExpression { get; private set; } + + public BaseBoundExpression StepExpressionOpt { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.FromExpression; + yield return this.ToExpression; + if (!this.StepExpressionOpt.IsDefault()) + { + yield return this.StepExpressionOpt; + } + + yield return this.Body; + } + } + } + + internal sealed class BoundForEachStatement : BaseBoundStatement + { + public BoundForEachStatement(ForEachStatementSyntax syntax, string identifier, BaseBoundExpression collection, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!identifier.IsDefault(), "'identifier' must not be null."); + Debug.Assert(!collection.IsDefault(), "'collection' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Identifier = identifier; + this.Collection = collection; + this.Body = body; + } + + public ForEachStatementSyntax Syntax { get; private set; } + + public string Identifier { get; private set; } + + public BaseBoundExpression Collection { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Collection; + yield return this.Body; + } + } + } + + internal sealed class BoundCaseClause : BaseBoundNode + { + public BoundCaseClause(CaseClauseSyntax syntax, bool isElse, BaseBoundExpression valueExpressionOpt, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!isElse.IsDefault(), "'isElse' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.IsElse = isElse; + this.ValueExpressionOpt = valueExpressionOpt; + this.Body = body; + } + + public CaseClauseSyntax Syntax { get; private set; } + + public bool IsElse { get; private set; } + + public BaseBoundExpression ValueExpressionOpt { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + if (!this.ValueExpressionOpt.IsDefault()) + { + yield return this.ValueExpressionOpt; + } + + yield return this.Body; + } + } + } + + internal sealed class BoundSelectStatement : BaseBoundStatement + { + public BoundSelectStatement(SelectStatementSyntax syntax, BaseBoundExpression expression, IReadOnlyList cases) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + Debug.Assert(!cases.IsDefault(), "'cases' must not be null."); + + this.Syntax = syntax; + this.Expression = expression; + this.Cases = cases; + } + + public SelectStatementSyntax Syntax { get; private set; } + + public BaseBoundExpression Expression { get; private set; } + + public IReadOnlyList Cases { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + foreach (var child in this.Cases) + { + yield return child; + } + } + } + } + + internal sealed class BoundCatchClause : BaseBoundNode + { + public BoundCatchClause(CatchClauseSyntax syntax, string variableOpt, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.VariableOpt = variableOpt; + this.Body = body; + } + + public CatchClauseSyntax Syntax { get; private set; } + + public string VariableOpt { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + } + } + } + + internal sealed class BoundFinallyClause : BaseBoundNode + { + public BoundFinallyClause(FinallyClauseSyntax syntax, BoundStatementBlock body) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Body = body; + } + + public FinallyClauseSyntax Syntax { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + } + } + } + + internal sealed class BoundTryStatement : BaseBoundStatement + { + public BoundTryStatement(TryStatementSyntax syntax, BoundStatementBlock body, BoundCatchClause catchClauseOpt, BoundFinallyClause finallyClauseOpt) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Syntax = syntax; + this.Body = body; + this.CatchClauseOpt = catchClauseOpt; + this.FinallyClauseOpt = finallyClauseOpt; + } + + public TryStatementSyntax Syntax { get; private set; } + + public BoundStatementBlock Body { get; private set; } + + public BoundCatchClause CatchClauseOpt { get; private set; } + + public BoundFinallyClause FinallyClauseOpt { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + if (!this.CatchClauseOpt.IsDefault()) + { + yield return this.CatchClauseOpt; + } + + if (!this.FinallyClauseOpt.IsDefault()) + { + yield return this.FinallyClauseOpt; + } + } + } + } + + internal sealed class BoundLabelStatement : BaseBoundStatement + { + public BoundLabelStatement(LabelStatementSyntax syntax, string label) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!label.IsDefault(), "'label' must not be null."); + + this.Syntax = syntax; + this.Label = label; + } + + public LabelStatementSyntax Syntax { get; private set; } + + public string Label { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + } + + internal sealed class BoundGoToStatement : BaseBoundStatement + { + public BoundGoToStatement(GoToStatementSyntax syntax, string label) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!label.IsDefault(), "'label' must not be null."); + + this.Syntax = syntax; + this.Label = label; + } + + public GoToStatementSyntax Syntax { get; private set; } + + public string Label { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + } + + internal sealed class BoundSubModuleInvocationStatement : BaseBoundStatement + { + public BoundSubModuleInvocationStatement(ExpressionStatementSyntax syntax, BoundSubModuleInvocationExpression expression) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.Syntax = syntax; + this.Expression = expression; + } + + public ExpressionStatementSyntax Syntax { get; private set; } + + public BoundSubModuleInvocationExpression Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + } + + internal sealed class BoundLibraryMethodInvocationStatement : BaseBoundStatement + { + public BoundLibraryMethodInvocationStatement(ExpressionStatementSyntax syntax, BoundLibraryMethodInvocationExpression expression) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.Syntax = syntax; + this.Expression = expression; + } + + public ExpressionStatementSyntax Syntax { get; private set; } + + public BoundLibraryMethodInvocationExpression Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + } + + internal sealed class BoundVariableAssignmentStatement : BaseBoundStatement + { + public BoundVariableAssignmentStatement(ExpressionStatementSyntax syntax, BoundVariableExpression variable, BaseBoundExpression expression) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!variable.IsDefault(), "'variable' must not be null."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.Syntax = syntax; + this.Variable = variable; + this.Expression = expression; + } + + public ExpressionStatementSyntax Syntax { get; private set; } + + public BoundVariableExpression Variable { get; private set; } + + public BaseBoundExpression Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Variable; + yield return this.Expression; + } + } + } + + internal sealed class BoundPropertyAssignmentStatement : BaseBoundStatement + { + public BoundPropertyAssignmentStatement(ExpressionStatementSyntax syntax, BoundLibraryPropertyExpression property, BaseBoundExpression expression) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!property.IsDefault(), "'property' must not be null."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.Syntax = syntax; + this.Property = property; + this.Expression = expression; + } + + public ExpressionStatementSyntax Syntax { get; private set; } + + public BoundLibraryPropertyExpression Property { get; private set; } + + public BaseBoundExpression Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Property; + yield return this.Expression; + } + } + } + + internal sealed class BoundEventAssignmentStatement : BaseBoundStatement + { + public BoundEventAssignmentStatement(ExpressionStatementSyntax syntax, BoundLibraryEventExpression usedEvent, string subModule) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!usedEvent.IsDefault(), "'usedEvent' must not be null."); + Debug.Assert(!subModule.IsDefault(), "'subModule' must not be null."); + + this.Syntax = syntax; + this.UsedEvent = usedEvent; + this.SubModule = subModule; + } + + public ExpressionStatementSyntax Syntax { get; private set; } + + public BoundLibraryEventExpression UsedEvent { get; private set; } + + public string SubModule { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.UsedEvent; + } + } + } + + internal sealed class BoundArrayAssignmentStatement : BaseBoundStatement + { + public BoundArrayAssignmentStatement(ExpressionStatementSyntax syntax, BoundArrayAccessExpression array, BaseBoundExpression expression) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!array.IsDefault(), "'array' must not be null."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.Syntax = syntax; + this.Array = array; + this.Expression = expression; + } + + public ExpressionStatementSyntax Syntax { get; private set; } + + public BoundArrayAccessExpression Array { get; private set; } + + public BaseBoundExpression Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Array; + yield return this.Expression; + } + } + } + + internal sealed class BoundInvalidExpressionStatement : BaseBoundStatement + { + public BoundInvalidExpressionStatement(ExpressionStatementSyntax syntax, BaseBoundExpression expression) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.Syntax = syntax; + this.Expression = expression; + } + + public ExpressionStatementSyntax Syntax { get; private set; } + + public BaseBoundExpression Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + } + + internal abstract class BaseBoundExpression : BaseBoundNode + { + public BaseBoundExpression(bool hasValue, bool hasErrors) + { + Debug.Assert(!hasValue.IsDefault(), "'hasValue' must not be null."); + Debug.Assert(!hasErrors.IsDefault(), "'hasErrors' must not be null."); + + this.HasValue = hasValue; + this.HasErrors = hasErrors; + } + + public bool HasValue { get; private set; } + + public bool HasErrors { get; private set; } + } + + internal sealed class BoundUnaryExpression : BaseBoundExpression + { + public BoundUnaryExpression(UnaryOperatorExpressionSyntax syntax, bool hasValue, bool hasErrors, TokenKind kind, BaseBoundExpression expression) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!kind.IsDefault(), "'kind' must not be null."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.Syntax = syntax; + this.Kind = kind; + this.Expression = expression; + } + + public UnaryOperatorExpressionSyntax Syntax { get; private set; } + + public TokenKind Kind { get; private set; } + + public BaseBoundExpression Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + } + + internal sealed class BoundBinaryExpression : BaseBoundExpression + { + public BoundBinaryExpression(BinaryOperatorExpressionSyntax syntax, bool hasValue, bool hasErrors, TokenKind kind, BaseBoundExpression left, BaseBoundExpression right) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!kind.IsDefault(), "'kind' must not be null."); + Debug.Assert(!left.IsDefault(), "'left' must not be null."); + Debug.Assert(!right.IsDefault(), "'right' must not be null."); + + this.Syntax = syntax; + this.Kind = kind; + this.Left = left; + this.Right = right; + } + + public BinaryOperatorExpressionSyntax Syntax { get; private set; } + + public TokenKind Kind { get; private set; } + + public BaseBoundExpression Left { get; private set; } + + public BaseBoundExpression Right { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Left; + yield return this.Right; + } + } + } + + internal sealed class BoundArrayAccessExpression : BaseBoundExpression + { + public BoundArrayAccessExpression(ArrayAccessExpressionSyntax syntax, bool hasValue, bool hasErrors, string name, IReadOnlyList indices) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!name.IsDefault(), "'name' must not be null."); + Debug.Assert(!indices.IsDefault(), "'indices' must not be null."); + + this.Syntax = syntax; + this.Name = name; + this.Indices = indices; + } + + public ArrayAccessExpressionSyntax Syntax { get; private set; } + + public string Name { get; private set; } + + public IReadOnlyList Indices { get; private set; } + + public override IEnumerable Children + { + get + { + foreach (var child in this.Indices) + { + yield return child; + } + } + } + } + + internal sealed class BoundLibraryTypeExpression : BaseBoundExpression + { + public BoundLibraryTypeExpression(IdentifierExpressionSyntax syntax, bool hasValue, bool hasErrors, string name) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!name.IsDefault(), "'name' must not be null."); + + this.Syntax = syntax; + this.Name = name; + } + + public IdentifierExpressionSyntax Syntax { get; private set; } + + public string Name { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + } + + internal sealed class BoundLibraryMethodExpression : BaseBoundExpression + { + public BoundLibraryMethodExpression(ObjectAccessExpressionSyntax syntax, bool hasValue, bool hasErrors, BoundLibraryTypeExpression library, string name) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!library.IsDefault(), "'library' must not be null."); + Debug.Assert(!name.IsDefault(), "'name' must not be null."); + + this.Syntax = syntax; + this.Library = library; + this.Name = name; + } + + public ObjectAccessExpressionSyntax Syntax { get; private set; } + + public BoundLibraryTypeExpression Library { get; private set; } + + public string Name { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Library; + } + } + } + + internal sealed class BoundLibraryPropertyExpression : BaseBoundExpression + { + public BoundLibraryPropertyExpression(ObjectAccessExpressionSyntax syntax, bool hasValue, bool hasErrors, BoundLibraryTypeExpression library, string name) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!library.IsDefault(), "'library' must not be null."); + Debug.Assert(!name.IsDefault(), "'name' must not be null."); + + this.Syntax = syntax; + this.Library = library; + this.Name = name; + } + + public ObjectAccessExpressionSyntax Syntax { get; private set; } + + public BoundLibraryTypeExpression Library { get; private set; } + + public string Name { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Library; + } + } + } + + internal sealed class BoundLibraryEventExpression : BaseBoundExpression + { + public BoundLibraryEventExpression(ObjectAccessExpressionSyntax syntax, bool hasValue, bool hasErrors, BoundLibraryTypeExpression library, string name) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!library.IsDefault(), "'library' must not be null."); + Debug.Assert(!name.IsDefault(), "'name' must not be null."); + + this.Syntax = syntax; + this.Library = library; + this.Name = name; + } + + public ObjectAccessExpressionSyntax Syntax { get; private set; } + + public BoundLibraryTypeExpression Library { get; private set; } + + public string Name { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Library; + } + } + } + + internal sealed class BoundLibraryMethodInvocationExpression : BaseBoundExpression + { + public BoundLibraryMethodInvocationExpression(InvocationExpressionSyntax syntax, bool hasValue, bool hasErrors, BoundLibraryMethodExpression method, IReadOnlyList arguments) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!method.IsDefault(), "'method' must not be null."); + Debug.Assert(!arguments.IsDefault(), "'arguments' must not be null."); + + this.Syntax = syntax; + this.Method = method; + this.Arguments = arguments; + } + + public InvocationExpressionSyntax Syntax { get; private set; } + + public BoundLibraryMethodExpression Method { get; private set; } + + public IReadOnlyList Arguments { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Method; + foreach (var child in this.Arguments) + { + yield return child; + } + } + } + } + + internal sealed class BoundSubModuleExpression : BaseBoundExpression + { + public BoundSubModuleExpression(IdentifierExpressionSyntax syntax, bool hasValue, bool hasErrors, string name) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!name.IsDefault(), "'name' must not be null."); + + this.Syntax = syntax; + this.Name = name; + } + + public IdentifierExpressionSyntax Syntax { get; private set; } + + public string Name { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + } + + internal sealed class BoundSubModuleInvocationExpression : BaseBoundExpression + { + public BoundSubModuleInvocationExpression(InvocationExpressionSyntax syntax, bool hasValue, bool hasErrors, string name, IReadOnlyList arguments) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!name.IsDefault(), "'name' must not be null."); + Debug.Assert(!arguments.IsDefault(), "'arguments' must not be null."); + + this.Syntax = syntax; + this.Name = name; + this.Arguments = arguments; + } + + public InvocationExpressionSyntax Syntax { get; private set; } + + public string Name { get; private set; } + + public IReadOnlyList Arguments { get; private set; } + + public override IEnumerable Children + { + get + { + foreach (var child in this.Arguments) + { + yield return child; + } + } + } + } + + internal sealed class BoundVariableExpression : BaseBoundExpression + { + public BoundVariableExpression(IdentifierExpressionSyntax syntax, bool hasValue, bool hasErrors, string name) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!name.IsDefault(), "'name' must not be null."); + + this.Syntax = syntax; + this.Name = name; + } + + public IdentifierExpressionSyntax Syntax { get; private set; } + + public string Name { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + } + + internal sealed class BoundStringLiteralExpression : BaseBoundExpression + { + public BoundStringLiteralExpression(StringLiteralExpressionSyntax syntax, bool hasValue, bool hasErrors, string value) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!value.IsDefault(), "'value' must not be null."); + + this.Syntax = syntax; + this.Value = value; + } + + public StringLiteralExpressionSyntax Syntax { get; private set; } + + public string Value { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + } + + internal sealed class BoundNumberLiteralExpression : BaseBoundExpression + { + public BoundNumberLiteralExpression(NumberLiteralExpressionSyntax syntax, bool hasValue, bool hasErrors, decimal value) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!value.IsDefault(), "'value' must not be null."); + + this.Syntax = syntax; + this.Value = value; + } + + public NumberLiteralExpressionSyntax Syntax { get; private set; } + + public decimal Value { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + } + + internal sealed class BoundParenthesisExpression : BaseBoundExpression + { + public BoundParenthesisExpression(ParenthesisExpressionSyntax syntax, bool hasValue, bool hasErrors, BaseBoundExpression expression) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.Syntax = syntax; + this.Expression = expression; + } + + public ParenthesisExpressionSyntax Syntax { get; private set; } + + public BaseBoundExpression Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + } + + internal sealed class BoundInvalidExpression : BaseBoundExpression + { + public BoundInvalidExpression(BaseExpressionSyntax syntax, bool hasValue, bool hasErrors) + : base(hasValue, hasErrors) + { + Debug.Assert(!syntax.IsDefault(), "'syntax' must not be null."); + + this.Syntax = syntax; + } + + public BaseExpressionSyntax Syntax { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + } +} diff --git a/Source/SmallBasic.Compiler/Diagnostics/DiagnosticBag.Generated.cs b/Source/SmallBasic.Compiler/Diagnostics/DiagnosticBag.Generated.cs index bd1f47df..098d48e6 100644 --- a/Source/SmallBasic.Compiler/Diagnostics/DiagnosticBag.Generated.cs +++ b/Source/SmallBasic.Compiler/Diagnostics/DiagnosticBag.Generated.cs @@ -1,130 +1,130 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Compiler.Diagnostics -{ - using System.Collections.Generic; - using SmallBasic.Compiler.Scanning; - using SmallBasic.Utilities; - - internal sealed class DiagnosticBag - { - private readonly List builder = new List(); - - public IReadOnlyList Contents => this.builder; - - public void ReportUnrecognizedCharacter(TextRange range, char character) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnrecognizedCharacter, range, character.ToDisplayString())); - } - - public void ReportUnterminatedStringLiteral(TextRange range) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnterminatedStringLiteral, range)); - } - - public void ReportUnexpectedTokenFound(TextRange range, TokenKind found, TokenKind expected) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedTokenFound, range, found.ToDisplayString(), expected.ToDisplayString())); - } - - public void ReportUnexpectedEndOfStream(TextRange range, TokenKind expected) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedEndOfStream, range, expected.ToDisplayString())); - } - - public void ReportUnexpectedStatementInsteadOfNewLine(TextRange range) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedStatementInsteadOfNewLine, range)); - } - - public void ReportUnexpectedTokenInsteadOfStatement(TextRange range, TokenKind found) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedTokenInsteadOfStatement, range, found.ToDisplayString())); - } - - public void ReportTwoSubModulesWithTheSameName(TextRange range, string name) - { - this.builder.Add(new Diagnostic(DiagnosticCode.TwoSubModulesWithTheSameName, range, name.ToDisplayString())); - } - - public void ReportTwoLabelsWithTheSameName(TextRange range, string label) - { - this.builder.Add(new Diagnostic(DiagnosticCode.TwoLabelsWithTheSameName, range, label.ToDisplayString())); - } - - public void ReportGoToUndefinedLabel(TextRange range, string label) - { - this.builder.Add(new Diagnostic(DiagnosticCode.GoToUndefinedLabel, range, label.ToDisplayString())); - } - - public void ReportPropertyHasNoSetter(TextRange range, string library, string property) - { - this.builder.Add(new Diagnostic(DiagnosticCode.PropertyHasNoSetter, range, library.ToDisplayString(), property.ToDisplayString())); - } - - public void ReportAssigningNonSubModuleToEvent(TextRange range) - { - this.builder.Add(new Diagnostic(DiagnosticCode.AssigningNonSubModuleToEvent, range)); - } - - public void ReportUnassignedExpressionStatement(TextRange range) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnassignedExpressionStatement, range)); - } - - public void ReportInvalidExpressionStatement(TextRange range) - { - this.builder.Add(new Diagnostic(DiagnosticCode.InvalidExpressionStatement, range)); - } - - public void ReportUnsupportedArrayBaseExpression(TextRange range) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnsupportedArrayBaseExpression, range)); - } - - public void ReportValueIsNotANumber(TextRange range, string value) - { - this.builder.Add(new Diagnostic(DiagnosticCode.ValueIsNotANumber, range, value.ToDisplayString())); - } - - public void ReportUnsupportedDotBaseExpression(TextRange range) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnsupportedDotBaseExpression, range)); - } - - public void ReportExpectedExpressionWithAValue(TextRange range) - { - this.builder.Add(new Diagnostic(DiagnosticCode.ExpectedExpressionWithAValue, range)); - } - - public void ReportLibraryMemberNotFound(TextRange range, string library, string member) - { - this.builder.Add(new Diagnostic(DiagnosticCode.LibraryMemberNotFound, range, library.ToDisplayString(), member.ToDisplayString())); - } - - public void ReportUnexpectedArgumentsCount(TextRange range, int actualCount, int expectedCount) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedArgumentsCount, range, actualCount.ToDisplayString(), expectedCount.ToDisplayString())); - } - - public void ReportUnsupportedInvocationBaseExpression(TextRange range) - { - this.builder.Add(new Diagnostic(DiagnosticCode.UnsupportedInvocationBaseExpression, range)); - } - - public void ReportLibraryMemberDeprecatedFromOlderVersion(TextRange range, string library, string member) - { - this.builder.Add(new Diagnostic(DiagnosticCode.LibraryMemberDeprecatedFromOlderVersion, range, library.ToDisplayString(), member.ToDisplayString())); - } - - public void ReportLibraryMemberNeedsDesktop(TextRange range, string library, string member) - { - this.builder.Add(new Diagnostic(DiagnosticCode.LibraryMemberNeedsDesktop, range, library.ToDisplayString(), member.ToDisplayString())); - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Compiler.Diagnostics +{ + using System.Collections.Generic; + using SmallBasic.Compiler.Scanning; + using SmallBasic.Utilities; + + internal sealed class DiagnosticBag + { + private readonly List builder = new List(); + + public IReadOnlyList Contents => this.builder; + + public void ReportUnrecognizedCharacter(TextRange range, char character) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnrecognizedCharacter, range, character.ToDisplayString())); + } + + public void ReportUnterminatedStringLiteral(TextRange range) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnterminatedStringLiteral, range)); + } + + public void ReportUnexpectedTokenFound(TextRange range, TokenKind found, TokenKind expected) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedTokenFound, range, found.ToDisplayString(), expected.ToDisplayString())); + } + + public void ReportUnexpectedEndOfStream(TextRange range, TokenKind expected) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedEndOfStream, range, expected.ToDisplayString())); + } + + public void ReportUnexpectedStatementInsteadOfNewLine(TextRange range) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedStatementInsteadOfNewLine, range)); + } + + public void ReportUnexpectedTokenInsteadOfStatement(TextRange range, TokenKind found) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedTokenInsteadOfStatement, range, found.ToDisplayString())); + } + + public void ReportTwoSubModulesWithTheSameName(TextRange range, string name) + { + this.builder.Add(new Diagnostic(DiagnosticCode.TwoSubModulesWithTheSameName, range, name.ToDisplayString())); + } + + public void ReportTwoLabelsWithTheSameName(TextRange range, string label) + { + this.builder.Add(new Diagnostic(DiagnosticCode.TwoLabelsWithTheSameName, range, label.ToDisplayString())); + } + + public void ReportGoToUndefinedLabel(TextRange range, string label) + { + this.builder.Add(new Diagnostic(DiagnosticCode.GoToUndefinedLabel, range, label.ToDisplayString())); + } + + public void ReportPropertyHasNoSetter(TextRange range, string library, string property) + { + this.builder.Add(new Diagnostic(DiagnosticCode.PropertyHasNoSetter, range, library.ToDisplayString(), property.ToDisplayString())); + } + + public void ReportAssigningNonSubModuleToEvent(TextRange range) + { + this.builder.Add(new Diagnostic(DiagnosticCode.AssigningNonSubModuleToEvent, range)); + } + + public void ReportUnassignedExpressionStatement(TextRange range) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnassignedExpressionStatement, range)); + } + + public void ReportInvalidExpressionStatement(TextRange range) + { + this.builder.Add(new Diagnostic(DiagnosticCode.InvalidExpressionStatement, range)); + } + + public void ReportUnsupportedArrayBaseExpression(TextRange range) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnsupportedArrayBaseExpression, range)); + } + + public void ReportValueIsNotANumber(TextRange range, string value) + { + this.builder.Add(new Diagnostic(DiagnosticCode.ValueIsNotANumber, range, value.ToDisplayString())); + } + + public void ReportUnsupportedDotBaseExpression(TextRange range) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnsupportedDotBaseExpression, range)); + } + + public void ReportExpectedExpressionWithAValue(TextRange range) + { + this.builder.Add(new Diagnostic(DiagnosticCode.ExpectedExpressionWithAValue, range)); + } + + public void ReportLibraryMemberNotFound(TextRange range, string library, string member) + { + this.builder.Add(new Diagnostic(DiagnosticCode.LibraryMemberNotFound, range, library.ToDisplayString(), member.ToDisplayString())); + } + + public void ReportUnexpectedArgumentsCount(TextRange range, int actualCount, int expectedCount) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnexpectedArgumentsCount, range, actualCount.ToDisplayString(), expectedCount.ToDisplayString())); + } + + public void ReportUnsupportedInvocationBaseExpression(TextRange range) + { + this.builder.Add(new Diagnostic(DiagnosticCode.UnsupportedInvocationBaseExpression, range)); + } + + public void ReportLibraryMemberDeprecatedFromOlderVersion(TextRange range, string library, string member) + { + this.builder.Add(new Diagnostic(DiagnosticCode.LibraryMemberDeprecatedFromOlderVersion, range, library.ToDisplayString(), member.ToDisplayString())); + } + + public void ReportLibraryMemberNeedsDesktop(TextRange range, string library, string member) + { + this.builder.Add(new Diagnostic(DiagnosticCode.LibraryMemberNeedsDesktop, range, library.ToDisplayString(), member.ToDisplayString())); + } + } +} diff --git a/Source/SmallBasic.Compiler/Diagnostics/DiagnosticCode.Generated.cs b/Source/SmallBasic.Compiler/Diagnostics/DiagnosticCode.Generated.cs index b7aaf1e5..47427303 100644 --- a/Source/SmallBasic.Compiler/Diagnostics/DiagnosticCode.Generated.cs +++ b/Source/SmallBasic.Compiler/Diagnostics/DiagnosticCode.Generated.cs @@ -1,71 +1,71 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Compiler.Diagnostics -{ - using SmallBasic.Utilities; - using SmallBasic.Utilities.Resources; - - public enum DiagnosticCode - { - UnrecognizedCharacter, - UnterminatedStringLiteral, - UnexpectedTokenFound, - UnexpectedEndOfStream, - UnexpectedStatementInsteadOfNewLine, - UnexpectedTokenInsteadOfStatement, - TwoSubModulesWithTheSameName, - TwoLabelsWithTheSameName, - GoToUndefinedLabel, - PropertyHasNoSetter, - AssigningNonSubModuleToEvent, - UnassignedExpressionStatement, - InvalidExpressionStatement, - UnsupportedArrayBaseExpression, - ValueIsNotANumber, - UnsupportedDotBaseExpression, - ExpectedExpressionWithAValue, - LibraryMemberNotFound, - UnexpectedArgumentsCount, - UnsupportedInvocationBaseExpression, - LibraryMemberDeprecatedFromOlderVersion, - LibraryMemberNeedsDesktop, - } - - internal static partial class DiagnosticCodeExtensions - { - public static string ToDisplayString(this DiagnosticCode kind) - { - switch (kind) - { - case DiagnosticCode.UnrecognizedCharacter: return DiagnosticsResources.UnrecognizedCharacter; - case DiagnosticCode.UnterminatedStringLiteral: return DiagnosticsResources.UnterminatedStringLiteral; - case DiagnosticCode.UnexpectedTokenFound: return DiagnosticsResources.UnexpectedTokenFound; - case DiagnosticCode.UnexpectedEndOfStream: return DiagnosticsResources.UnexpectedEndOfStream; - case DiagnosticCode.UnexpectedStatementInsteadOfNewLine: return DiagnosticsResources.UnexpectedStatementInsteadOfNewLine; - case DiagnosticCode.UnexpectedTokenInsteadOfStatement: return DiagnosticsResources.UnexpectedTokenInsteadOfStatement; - case DiagnosticCode.TwoSubModulesWithTheSameName: return DiagnosticsResources.TwoSubModulesWithTheSameName; - case DiagnosticCode.TwoLabelsWithTheSameName: return DiagnosticsResources.TwoLabelsWithTheSameName; - case DiagnosticCode.GoToUndefinedLabel: return DiagnosticsResources.GoToUndefinedLabel; - case DiagnosticCode.PropertyHasNoSetter: return DiagnosticsResources.PropertyHasNoSetter; - case DiagnosticCode.AssigningNonSubModuleToEvent: return DiagnosticsResources.AssigningNonSubModuleToEvent; - case DiagnosticCode.UnassignedExpressionStatement: return DiagnosticsResources.UnassignedExpressionStatement; - case DiagnosticCode.InvalidExpressionStatement: return DiagnosticsResources.InvalidExpressionStatement; - case DiagnosticCode.UnsupportedArrayBaseExpression: return DiagnosticsResources.UnsupportedArrayBaseExpression; - case DiagnosticCode.ValueIsNotANumber: return DiagnosticsResources.ValueIsNotANumber; - case DiagnosticCode.UnsupportedDotBaseExpression: return DiagnosticsResources.UnsupportedDotBaseExpression; - case DiagnosticCode.ExpectedExpressionWithAValue: return DiagnosticsResources.ExpectedExpressionWithAValue; - case DiagnosticCode.LibraryMemberNotFound: return DiagnosticsResources.LibraryMemberNotFound; - case DiagnosticCode.UnexpectedArgumentsCount: return DiagnosticsResources.UnexpectedArgumentsCount; - case DiagnosticCode.UnsupportedInvocationBaseExpression: return DiagnosticsResources.UnsupportedInvocationBaseExpression; - case DiagnosticCode.LibraryMemberDeprecatedFromOlderVersion: return DiagnosticsResources.LibraryMemberDeprecatedFromOlderVersion; - case DiagnosticCode.LibraryMemberNeedsDesktop: return DiagnosticsResources.LibraryMemberNeedsDesktop; - default: throw ExceptionUtilities.UnexpectedValue(kind); - } - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Compiler.Diagnostics +{ + using SmallBasic.Utilities; + using SmallBasic.Utilities.Resources; + + public enum DiagnosticCode + { + UnrecognizedCharacter, + UnterminatedStringLiteral, + UnexpectedTokenFound, + UnexpectedEndOfStream, + UnexpectedStatementInsteadOfNewLine, + UnexpectedTokenInsteadOfStatement, + TwoSubModulesWithTheSameName, + TwoLabelsWithTheSameName, + GoToUndefinedLabel, + PropertyHasNoSetter, + AssigningNonSubModuleToEvent, + UnassignedExpressionStatement, + InvalidExpressionStatement, + UnsupportedArrayBaseExpression, + ValueIsNotANumber, + UnsupportedDotBaseExpression, + ExpectedExpressionWithAValue, + LibraryMemberNotFound, + UnexpectedArgumentsCount, + UnsupportedInvocationBaseExpression, + LibraryMemberDeprecatedFromOlderVersion, + LibraryMemberNeedsDesktop, + } + + internal static partial class DiagnosticCodeExtensions + { + public static string ToDisplayString(this DiagnosticCode kind) + { + switch (kind) + { + case DiagnosticCode.UnrecognizedCharacter: return DiagnosticsResources.UnrecognizedCharacter; + case DiagnosticCode.UnterminatedStringLiteral: return DiagnosticsResources.UnterminatedStringLiteral; + case DiagnosticCode.UnexpectedTokenFound: return DiagnosticsResources.UnexpectedTokenFound; + case DiagnosticCode.UnexpectedEndOfStream: return DiagnosticsResources.UnexpectedEndOfStream; + case DiagnosticCode.UnexpectedStatementInsteadOfNewLine: return DiagnosticsResources.UnexpectedStatementInsteadOfNewLine; + case DiagnosticCode.UnexpectedTokenInsteadOfStatement: return DiagnosticsResources.UnexpectedTokenInsteadOfStatement; + case DiagnosticCode.TwoSubModulesWithTheSameName: return DiagnosticsResources.TwoSubModulesWithTheSameName; + case DiagnosticCode.TwoLabelsWithTheSameName: return DiagnosticsResources.TwoLabelsWithTheSameName; + case DiagnosticCode.GoToUndefinedLabel: return DiagnosticsResources.GoToUndefinedLabel; + case DiagnosticCode.PropertyHasNoSetter: return DiagnosticsResources.PropertyHasNoSetter; + case DiagnosticCode.AssigningNonSubModuleToEvent: return DiagnosticsResources.AssigningNonSubModuleToEvent; + case DiagnosticCode.UnassignedExpressionStatement: return DiagnosticsResources.UnassignedExpressionStatement; + case DiagnosticCode.InvalidExpressionStatement: return DiagnosticsResources.InvalidExpressionStatement; + case DiagnosticCode.UnsupportedArrayBaseExpression: return DiagnosticsResources.UnsupportedArrayBaseExpression; + case DiagnosticCode.ValueIsNotANumber: return DiagnosticsResources.ValueIsNotANumber; + case DiagnosticCode.UnsupportedDotBaseExpression: return DiagnosticsResources.UnsupportedDotBaseExpression; + case DiagnosticCode.ExpectedExpressionWithAValue: return DiagnosticsResources.ExpectedExpressionWithAValue; + case DiagnosticCode.LibraryMemberNotFound: return DiagnosticsResources.LibraryMemberNotFound; + case DiagnosticCode.UnexpectedArgumentsCount: return DiagnosticsResources.UnexpectedArgumentsCount; + case DiagnosticCode.UnsupportedInvocationBaseExpression: return DiagnosticsResources.UnsupportedInvocationBaseExpression; + case DiagnosticCode.LibraryMemberDeprecatedFromOlderVersion: return DiagnosticsResources.LibraryMemberDeprecatedFromOlderVersion; + case DiagnosticCode.LibraryMemberNeedsDesktop: return DiagnosticsResources.LibraryMemberNeedsDesktop; + default: throw ExceptionUtilities.UnexpectedValue(kind); + } + } + } +} diff --git a/Source/SmallBasic.Compiler/Parsing/Parser.cs b/Source/SmallBasic.Compiler/Parsing/Parser.cs index e2a9e3e0..e5cef64e 100644 --- a/Source/SmallBasic.Compiler/Parsing/Parser.cs +++ b/Source/SmallBasic.Compiler/Parsing/Parser.cs @@ -1,4 +1,4 @@ -// +// // Licensed under the MIT License. See LICENSE file in the project root for license information. // @@ -46,6 +46,8 @@ public Parser(IReadOnlyList tokens, DiagnosticBag diagnostics) switch (this.Peek()) { case TokenKind.Sub: + case TokenKind.Function: + case TokenKind.Fn: statements.Add(this.ParseSubModuleDeclaration()); break; default: @@ -59,17 +61,73 @@ public Parser(IReadOnlyList tokens, DiagnosticBag diagnostics) public StatementBlockSyntax SyntaxTree { get; private set; } - private SubModuleStatementSyntax ParseSubModuleDeclaration() + private BaseStatementSyntax ParseSubModuleDeclaration() { - var subToken = this.Eat(TokenKind.Sub); + var startKind = this.Peek(); + var subToken = this.Eat(startKind); var nameToken = this.Eat(TokenKind.Identifier); + + Token leftParenOpt = null; + Token rightParenOpt = null; + List parameters = new List(); + + if (this.index < this.tokens.Count && this.Peek() == TokenKind.LeftParen) + { + leftParenOpt = this.Eat(TokenKind.LeftParen); + while (this.index < this.tokens.Count && this.Peek() != TokenKind.RightParen) + { + var paramIdentifier = this.Eat(TokenKind.Identifier); + Token commaOpt = null; + if (this.index < this.tokens.Count && this.Peek() == TokenKind.Comma) + { + commaOpt = this.Eat(TokenKind.Comma); + } + + parameters.Add(new ParameterSyntax(paramIdentifier, commaOpt)); + if (commaOpt.IsDefault()) + { + break; + } + } + + if (this.index < this.tokens.Count && this.Peek() == TokenKind.RightParen) + { + rightParenOpt = this.Eat(TokenKind.RightParen); + } + } + this.RunToEndOfLine(); - var statements = this.ParseStatementsExcept(TokenKind.Sub, TokenKind.EndSub); + TokenKind endKind1 = TokenKind.EndSub; + TokenKind endKind2 = TokenKind.EndFunction; + TokenKind endKind3 = TokenKind.EndFn; + + if (startKind == TokenKind.Function || startKind == TokenKind.Fn) + { + endKind1 = TokenKind.EndFunction; + endKind2 = TokenKind.EndFn; + endKind3 = TokenKind.EndSub; + } + + var statements = this.ParseStatementsExcept(TokenKind.Sub, TokenKind.Function, TokenKind.Fn, endKind1, endKind2, endKind3); + + Token endSubToken = null; + if (this.index < this.tokens.Count && (this.Peek() == endKind1 || this.Peek() == endKind2 || this.Peek() == endKind3 || this.Peek() == TokenKind.EndSub || this.Peek() == TokenKind.EndFunction || this.Peek() == TokenKind.EndFn)) + { + endSubToken = this.Eat(this.Peek()); + } + else + { + endSubToken = this.Eat(endKind1); + } - var endSubToken = this.Eat(TokenKind.EndSub); this.RunToEndOfLine(); + if (startKind == TokenKind.Function || startKind == TokenKind.Fn || !leftParenOpt.IsDefault()) + { + return new FunctionDeclarationSyntax(subToken, nameToken, leftParenOpt, parameters, rightParenOpt, statements, endSubToken); + } + return new SubModuleStatementSyntax(subToken, nameToken, statements, endSubToken); } @@ -92,8 +150,14 @@ private BaseStatementSyntax ParseStatement() return this.ParseIfStatement(); case TokenKind.For: return this.ParseForStatement(); + case TokenKind.ForEach: + return this.ParseForEachStatement(); case TokenKind.While: return this.ParseWhileStatement(); + case TokenKind.Select: + return this.ParseSelectStatement(); + case TokenKind.Try: + return this.ParseTryStatement(); case TokenKind.Identifier: if (this.index + 1 < this.tokens.Count && this.tokens[this.index + 1].Kind == TokenKind.Colon) @@ -110,6 +174,24 @@ private BaseStatementSyntax ParseStatement() return new ExpressionStatementSyntax(expression); } + case TokenKind.Return: + var returnToken = this.Eat(TokenKind.Return); + BaseExpressionSyntax returnExprOpt = null; + var currentLine = returnToken.Range.Start.Line; + if (this.index < this.tokens.Count && this.tokens[this.index].Range.Start.Line == currentLine && this.tokens[this.index].Kind != TokenKind.Comment) + { + returnExprOpt = this.ParseBaseExpression(); + } + + this.RunToEndOfLine(); + return new ReturnStatementSyntax(returnToken, returnExprOpt); + + case TokenKind.Import: + var importToken = this.Eat(TokenKind.Import); + var pathToken = this.Eat(TokenKind.StringLiteral); + this.RunToEndOfLine(); + return new ImportStatementSyntax(importToken, pathToken); + case TokenKind.GoTo: var goToToken = this.Eat(TokenKind.GoTo); var identifier = this.Eat(TokenKind.Identifier); @@ -199,6 +281,90 @@ private ForStatementSyntax ParseForStatement() return new ForStatementSyntax(forToken, identifierToken, equalToken, fromExpression, toToken, toExpression, stepClauseOpt, statements, endForToken); } + private ForEachStatementSyntax ParseForEachStatement() + { + var forEachToken = this.Eat(TokenKind.ForEach); + var identifierToken = this.Eat(TokenKind.Identifier); + var inToken = this.Eat(TokenKind.In); + var collectionExpr = this.ParseBaseExpression(); + this.RunToEndOfLine(); + + var statements = this.ParseStatementsExcept(TokenKind.EndFor); + var endForToken = this.Eat(TokenKind.EndFor); + this.RunToEndOfLine(); + + return new ForEachStatementSyntax(forEachToken, identifierToken, inToken, collectionExpr, statements, endForToken); + } + + private SelectStatementSyntax ParseSelectStatement() + { + var selectToken = this.Eat(TokenKind.Select); + if (this.Peek() == TokenKind.Case) + { + this.Eat(TokenKind.Case); + } + + var expression = this.ParseBaseExpression(); + this.RunToEndOfLine(); + + var cases = new List(); + while (this.index < this.tokens.Count && (this.Peek() == TokenKind.Case || this.Peek() == TokenKind.Else)) + { + var caseToken = this.Eat(this.Peek()); + BaseExpressionSyntax valExprOpt = null; + if (caseToken.Kind == TokenKind.Case) + { + valExprOpt = this.ParseBaseExpression(); + } + + this.RunToEndOfLine(); + var statements = this.ParseStatementsExcept(TokenKind.Case, TokenKind.Else, TokenKind.EndSelect); + cases.Add(new CaseClauseSyntax(caseToken, valExprOpt, statements)); + } + + var endSelectToken = this.Eat(TokenKind.EndSelect); + this.RunToEndOfLine(); + + return new SelectStatementSyntax(selectToken, expression, cases, endSelectToken); + } + + private TryStatementSyntax ParseTryStatement() + { + var tryToken = this.Eat(TokenKind.Try); + this.RunToEndOfLine(); + + var body = this.ParseStatementsExcept(TokenKind.Catch, TokenKind.Finally, TokenKind.EndTry); + + CatchClauseSyntax catchClauseOpt = null; + if (this.index < this.tokens.Count && this.Peek() == TokenKind.Catch) + { + var catchToken = this.Eat(TokenKind.Catch); + Token varTokenOpt = null; + if (this.index < this.tokens.Count && this.Peek() == TokenKind.Identifier) + { + varTokenOpt = this.Eat(TokenKind.Identifier); + } + + this.RunToEndOfLine(); + var catchBody = this.ParseStatementsExcept(TokenKind.Finally, TokenKind.EndTry); + catchClauseOpt = new CatchClauseSyntax(catchToken, varTokenOpt, catchBody); + } + + FinallyClauseSyntax finallyClauseOpt = null; + if (this.index < this.tokens.Count && this.Peek() == TokenKind.Finally) + { + var finallyToken = this.Eat(TokenKind.Finally); + this.RunToEndOfLine(); + var finallyBody = this.ParseStatementsExcept(TokenKind.EndTry); + finallyClauseOpt = new FinallyClauseSyntax(finallyToken, finallyBody); + } + + var endTryToken = this.Eat(TokenKind.EndTry); + this.RunToEndOfLine(); + + return new TryStatementSyntax(tryToken, body, catchClauseOpt, finallyClauseOpt, endTryToken); + } + private WhileStatementSyntax ParseWhileStatement() { var whileToken = this.Eat(TokenKind.While); diff --git a/Source/SmallBasic.Compiler/Parsing/SyntaxNodes.Generated.cs b/Source/SmallBasic.Compiler/Parsing/SyntaxNodes.Generated.cs index 3dd44ee8..eae1bf62 100644 --- a/Source/SmallBasic.Compiler/Parsing/SyntaxNodes.Generated.cs +++ b/Source/SmallBasic.Compiler/Parsing/SyntaxNodes.Generated.cs @@ -1,1486 +1,2153 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Compiler.Parsing -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; - using SmallBasic.Compiler.Scanning; - using SmallBasic.Utilities; - - public abstract class BaseSyntaxNodeVisitor - { - private protected void Visit(BaseSyntaxNode node) - { - switch (node) - { - case SubModuleStatementSyntax subModuleStatement: - this.VisitSubModuleStatement(subModuleStatement); - break; - case StatementBlockSyntax statementBlock: - this.VisitStatementBlock(statementBlock); - break; - case IfPartSyntax ifPart: - this.VisitIfPart(ifPart); - break; - case ElseIfPartSyntax elseIfPart: - this.VisitElseIfPart(elseIfPart); - break; - case ElsePartSyntax elsePart: - this.VisitElsePart(elsePart); - break; - case IfStatementSyntax ifStatement: - this.VisitIfStatement(ifStatement); - break; - case WhileStatementSyntax whileStatement: - this.VisitWhileStatement(whileStatement); - break; - case ForStepClauseSyntax forStepClause: - this.VisitForStepClause(forStepClause); - break; - case ForStatementSyntax forStatement: - this.VisitForStatement(forStatement); - break; - case LabelStatementSyntax labelStatement: - this.VisitLabelStatement(labelStatement); - break; - case GoToStatementSyntax goToStatement: - this.VisitGoToStatement(goToStatement); - break; - case UnrecognizedStatementSyntax unrecognizedStatement: - this.VisitUnrecognizedStatement(unrecognizedStatement); - break; - case ExpressionStatementSyntax expressionStatement: - this.VisitExpressionStatement(expressionStatement); - break; - case CommentStatementSyntax commentStatement: - this.VisitCommentStatement(commentStatement); - break; - case UnaryOperatorExpressionSyntax unaryOperatorExpression: - this.VisitUnaryOperatorExpression(unaryOperatorExpression); - break; - case BinaryOperatorExpressionSyntax binaryOperatorExpression: - this.VisitBinaryOperatorExpression(binaryOperatorExpression); - break; - case ObjectAccessExpressionSyntax objectAccessExpression: - this.VisitObjectAccessExpression(objectAccessExpression); - break; - case ArrayAccessExpressionSyntax arrayAccessExpression: - this.VisitArrayAccessExpression(arrayAccessExpression); - break; - case ArgumentSyntax argument: - this.VisitArgument(argument); - break; - case InvocationExpressionSyntax invocationExpression: - this.VisitInvocationExpression(invocationExpression); - break; - case ParenthesisExpressionSyntax parenthesisExpression: - this.VisitParenthesisExpression(parenthesisExpression); - break; - case IdentifierExpressionSyntax identifierExpression: - this.VisitIdentifierExpression(identifierExpression); - break; - case StringLiteralExpressionSyntax stringLiteralExpression: - this.VisitStringLiteralExpression(stringLiteralExpression); - break; - case NumberLiteralExpressionSyntax numberLiteralExpression: - this.VisitNumberLiteralExpression(numberLiteralExpression); - break; - case UnrecognizedExpressionSyntax unrecognizedExpression: - this.VisitUnrecognizedExpression(unrecognizedExpression); - break; - default: - throw ExceptionUtilities.UnexpectedValue(node); - } - } - - private protected virtual void VisitSubModuleStatement(SubModuleStatementSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitStatementBlock(StatementBlockSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitIfPart(IfPartSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitElseIfPart(ElseIfPartSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitElsePart(ElsePartSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitIfStatement(IfStatementSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitWhileStatement(WhileStatementSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitForStepClause(ForStepClauseSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitForStatement(ForStatementSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitLabelStatement(LabelStatementSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitGoToStatement(GoToStatementSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitUnrecognizedStatement(UnrecognizedStatementSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitExpressionStatement(ExpressionStatementSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitCommentStatement(CommentStatementSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitUnaryOperatorExpression(UnaryOperatorExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitBinaryOperatorExpression(BinaryOperatorExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitObjectAccessExpression(ObjectAccessExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitArrayAccessExpression(ArrayAccessExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitArgument(ArgumentSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitInvocationExpression(InvocationExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitParenthesisExpression(ParenthesisExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitIdentifierExpression(IdentifierExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitStringLiteralExpression(StringLiteralExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitNumberLiteralExpression(NumberLiteralExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private protected virtual void VisitUnrecognizedExpression(UnrecognizedExpressionSyntax node) - { - this.DefaultVisit(node); - } - - private void DefaultVisit(BaseSyntaxNode node) - { - foreach (var child in node.Children) - { - this.Visit(child); - } - } - } - - internal abstract class BaseStatementSyntax : BaseSyntaxNode - { - } - - internal sealed class SubModuleStatementSyntax : BaseStatementSyntax - { - public SubModuleStatementSyntax(Token subToken, Token nameToken, StatementBlockSyntax body, Token endSubToken) - { - Debug.Assert(!subToken.IsDefault(), "'subToken' must not be null."); - Debug.Assert(subToken.Kind == TokenKind.Sub, "'subToken' must have a TokenKind of 'Sub'."); - Debug.Assert(!nameToken.IsDefault(), "'nameToken' must not be null."); - Debug.Assert(nameToken.Kind == TokenKind.Identifier, "'nameToken' must have a TokenKind of 'Identifier'."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - Debug.Assert(!endSubToken.IsDefault(), "'endSubToken' must not be null."); - Debug.Assert(endSubToken.Kind == TokenKind.EndSub, "'endSubToken' must have a TokenKind of 'EndSub'."); - - this.SubToken = subToken; - this.NameToken = nameToken; - this.Body = body; - this.Body.Parent = this; - this.EndSubToken = endSubToken; - } - - public Token SubToken { get; private set; } - - public Token NameToken { get; private set; } - - public StatementBlockSyntax Body { get; private set; } - - public Token EndSubToken { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Body; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.SubToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.EndSubToken.Range.End; - } - } - } - } - - internal sealed class StatementBlockSyntax : BaseStatementSyntax - { - public StatementBlockSyntax(IReadOnlyList body) - { - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.Body = body; - foreach (var child in this.Body) - { - child.Parent = this; - } - } - - public IReadOnlyList Body { get; private set; } - - public override IEnumerable Children - { - get - { - foreach (var child in this.Body) - { - yield return child; - } - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - var bodyChild = this.Body.FirstOrDefault(); - if (!bodyChild.IsDefault()) - { - return bodyChild.Range.Start; - } - - return (0, 0); - } - - TextPosition calculateEnd() - { - var bodyChild = this.Body.LastOrDefault(); - if (!bodyChild.IsDefault()) - { - return bodyChild.Range.End; - } - - return (0, 0); - } - } - } - } - - internal sealed class IfPartSyntax : BaseSyntaxNode - { - public IfPartSyntax(Token ifToken, BaseExpressionSyntax condition, Token thenToken, StatementBlockSyntax body) - { - Debug.Assert(!ifToken.IsDefault(), "'ifToken' must not be null."); - Debug.Assert(ifToken.Kind == TokenKind.If, "'ifToken' must have a TokenKind of 'If'."); - Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); - Debug.Assert(!thenToken.IsDefault(), "'thenToken' must not be null."); - Debug.Assert(thenToken.Kind == TokenKind.Then, "'thenToken' must have a TokenKind of 'Then'."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.IfToken = ifToken; - this.Condition = condition; - this.Condition.Parent = this; - this.ThenToken = thenToken; - this.Body = body; - this.Body.Parent = this; - } - - public Token IfToken { get; private set; } - - public BaseExpressionSyntax Condition { get; private set; } - - public Token ThenToken { get; private set; } - - public StatementBlockSyntax Body { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Condition; - yield return this.Body; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.IfToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.Body.Range.End; - } - } - } - } - - internal sealed class ElseIfPartSyntax : BaseSyntaxNode - { - public ElseIfPartSyntax(Token elseIfToken, BaseExpressionSyntax condition, Token thenToken, StatementBlockSyntax body) - { - Debug.Assert(!elseIfToken.IsDefault(), "'elseIfToken' must not be null."); - Debug.Assert(elseIfToken.Kind == TokenKind.ElseIf, "'elseIfToken' must have a TokenKind of 'ElseIf'."); - Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); - Debug.Assert(!thenToken.IsDefault(), "'thenToken' must not be null."); - Debug.Assert(thenToken.Kind == TokenKind.Then, "'thenToken' must have a TokenKind of 'Then'."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.ElseIfToken = elseIfToken; - this.Condition = condition; - this.Condition.Parent = this; - this.ThenToken = thenToken; - this.Body = body; - this.Body.Parent = this; - } - - public Token ElseIfToken { get; private set; } - - public BaseExpressionSyntax Condition { get; private set; } - - public Token ThenToken { get; private set; } - - public StatementBlockSyntax Body { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Condition; - yield return this.Body; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.ElseIfToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.Body.Range.End; - } - } - } - } - - internal sealed class ElsePartSyntax : BaseSyntaxNode - { - public ElsePartSyntax(Token elseToken, StatementBlockSyntax body) - { - Debug.Assert(!elseToken.IsDefault(), "'elseToken' must not be null."); - Debug.Assert(elseToken.Kind == TokenKind.Else, "'elseToken' must have a TokenKind of 'Else'."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - - this.ElseToken = elseToken; - this.Body = body; - this.Body.Parent = this; - } - - public Token ElseToken { get; private set; } - - public StatementBlockSyntax Body { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Body; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.ElseToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.Body.Range.End; - } - } - } - } - - internal sealed class IfStatementSyntax : BaseStatementSyntax - { - public IfStatementSyntax(IfPartSyntax ifPart, IReadOnlyList elseIfParts, ElsePartSyntax elsePartOpt, Token endIfToken) - { - Debug.Assert(!ifPart.IsDefault(), "'ifPart' must not be null."); - Debug.Assert(!elseIfParts.IsDefault(), "'elseIfParts' must not be null."); - Debug.Assert(!endIfToken.IsDefault(), "'endIfToken' must not be null."); - Debug.Assert(endIfToken.Kind == TokenKind.EndIf, "'endIfToken' must have a TokenKind of 'EndIf'."); - - this.IfPart = ifPart; - this.IfPart.Parent = this; - this.ElseIfParts = elseIfParts; - foreach (var child in this.ElseIfParts) - { - child.Parent = this; - } - - this.ElsePartOpt = elsePartOpt; - if (!this.ElsePartOpt.IsDefault()) - { - this.ElsePartOpt.Parent = this; - } - - this.EndIfToken = endIfToken; - } - - public IfPartSyntax IfPart { get; private set; } - - public IReadOnlyList ElseIfParts { get; private set; } - - public ElsePartSyntax ElsePartOpt { get; private set; } - - public Token EndIfToken { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.IfPart; - foreach (var child in this.ElseIfParts) - { - yield return child; - } - - if (!this.ElsePartOpt.IsDefault()) - { - yield return this.ElsePartOpt; - } - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.IfPart.Range.Start; - } - - TextPosition calculateEnd() - { - return this.EndIfToken.Range.End; - } - } - } - } - - internal sealed class WhileStatementSyntax : BaseStatementSyntax - { - public WhileStatementSyntax(Token whileToken, BaseExpressionSyntax condition, StatementBlockSyntax body, Token endWhileToken) - { - Debug.Assert(!whileToken.IsDefault(), "'whileToken' must not be null."); - Debug.Assert(whileToken.Kind == TokenKind.While, "'whileToken' must have a TokenKind of 'While'."); - Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - Debug.Assert(!endWhileToken.IsDefault(), "'endWhileToken' must not be null."); - Debug.Assert(endWhileToken.Kind == TokenKind.EndWhile, "'endWhileToken' must have a TokenKind of 'EndWhile'."); - - this.WhileToken = whileToken; - this.Condition = condition; - this.Condition.Parent = this; - this.Body = body; - this.Body.Parent = this; - this.EndWhileToken = endWhileToken; - } - - public Token WhileToken { get; private set; } - - public BaseExpressionSyntax Condition { get; private set; } - - public StatementBlockSyntax Body { get; private set; } - - public Token EndWhileToken { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Condition; - yield return this.Body; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.WhileToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.EndWhileToken.Range.End; - } - } - } - } - - internal sealed class ForStepClauseSyntax : BaseSyntaxNode - { - public ForStepClauseSyntax(Token stepToken, BaseExpressionSyntax expression) - { - Debug.Assert(!stepToken.IsDefault(), "'stepToken' must not be null."); - Debug.Assert(stepToken.Kind == TokenKind.Step, "'stepToken' must have a TokenKind of 'Step'."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.StepToken = stepToken; - this.Expression = expression; - this.Expression.Parent = this; - } - - public Token StepToken { get; private set; } - - public BaseExpressionSyntax Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.StepToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.Expression.Range.End; - } - } - } - } - - internal sealed class ForStatementSyntax : BaseStatementSyntax - { - public ForStatementSyntax(Token forToken, Token identifierToken, Token equalToken, BaseExpressionSyntax fromExpression, Token toToken, BaseExpressionSyntax toExpression, ForStepClauseSyntax stepClauseOpt, StatementBlockSyntax body, Token endForToken) - { - Debug.Assert(!forToken.IsDefault(), "'forToken' must not be null."); - Debug.Assert(forToken.Kind == TokenKind.For, "'forToken' must have a TokenKind of 'For'."); - Debug.Assert(!identifierToken.IsDefault(), "'identifierToken' must not be null."); - Debug.Assert(identifierToken.Kind == TokenKind.Identifier, "'identifierToken' must have a TokenKind of 'Identifier'."); - Debug.Assert(!equalToken.IsDefault(), "'equalToken' must not be null."); - Debug.Assert(equalToken.Kind == TokenKind.Equal, "'equalToken' must have a TokenKind of 'Equal'."); - Debug.Assert(!fromExpression.IsDefault(), "'fromExpression' must not be null."); - Debug.Assert(!toToken.IsDefault(), "'toToken' must not be null."); - Debug.Assert(toToken.Kind == TokenKind.To, "'toToken' must have a TokenKind of 'To'."); - Debug.Assert(!toExpression.IsDefault(), "'toExpression' must not be null."); - Debug.Assert(!body.IsDefault(), "'body' must not be null."); - Debug.Assert(!endForToken.IsDefault(), "'endForToken' must not be null."); - Debug.Assert(endForToken.Kind == TokenKind.EndFor, "'endForToken' must have a TokenKind of 'EndFor'."); - - this.ForToken = forToken; - this.IdentifierToken = identifierToken; - this.EqualToken = equalToken; - this.FromExpression = fromExpression; - this.FromExpression.Parent = this; - this.ToToken = toToken; - this.ToExpression = toExpression; - this.ToExpression.Parent = this; - this.StepClauseOpt = stepClauseOpt; - if (!this.StepClauseOpt.IsDefault()) - { - this.StepClauseOpt.Parent = this; - } - - this.Body = body; - this.Body.Parent = this; - this.EndForToken = endForToken; - } - - public Token ForToken { get; private set; } - - public Token IdentifierToken { get; private set; } - - public Token EqualToken { get; private set; } - - public BaseExpressionSyntax FromExpression { get; private set; } - - public Token ToToken { get; private set; } - - public BaseExpressionSyntax ToExpression { get; private set; } - - public ForStepClauseSyntax StepClauseOpt { get; private set; } - - public StatementBlockSyntax Body { get; private set; } - - public Token EndForToken { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.FromExpression; - yield return this.ToExpression; - if (!this.StepClauseOpt.IsDefault()) - { - yield return this.StepClauseOpt; - } - - yield return this.Body; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.ForToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.EndForToken.Range.End; - } - } - } - } - - internal sealed class LabelStatementSyntax : BaseStatementSyntax - { - public LabelStatementSyntax(Token labelToken, Token colonToken) - { - Debug.Assert(!labelToken.IsDefault(), "'labelToken' must not be null."); - Debug.Assert(labelToken.Kind == TokenKind.Identifier, "'labelToken' must have a TokenKind of 'Identifier'."); - Debug.Assert(!colonToken.IsDefault(), "'colonToken' must not be null."); - Debug.Assert(colonToken.Kind == TokenKind.Colon, "'colonToken' must have a TokenKind of 'Colon'."); - - this.LabelToken = labelToken; - this.ColonToken = colonToken; - } - - public Token LabelToken { get; private set; } - - public Token ColonToken { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.LabelToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.ColonToken.Range.End; - } - } - } - } - - internal sealed class GoToStatementSyntax : BaseStatementSyntax - { - public GoToStatementSyntax(Token goToToken, Token labelToken) - { - Debug.Assert(!goToToken.IsDefault(), "'goToToken' must not be null."); - Debug.Assert(goToToken.Kind == TokenKind.GoTo, "'goToToken' must have a TokenKind of 'GoTo'."); - Debug.Assert(!labelToken.IsDefault(), "'labelToken' must not be null."); - Debug.Assert(labelToken.Kind == TokenKind.Identifier, "'labelToken' must have a TokenKind of 'Identifier'."); - - this.GoToToken = goToToken; - this.LabelToken = labelToken; - } - - public Token GoToToken { get; private set; } - - public Token LabelToken { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.GoToToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.LabelToken.Range.End; - } - } - } - } - - internal sealed class UnrecognizedStatementSyntax : BaseStatementSyntax - { - public UnrecognizedStatementSyntax(Token unrecognizedToken) - { - Debug.Assert(!unrecognizedToken.IsDefault(), "'unrecognizedToken' must not be null."); - - this.UnrecognizedToken = unrecognizedToken; - } - - public Token UnrecognizedToken { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.UnrecognizedToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.UnrecognizedToken.Range.End; - } - } - } - } - - internal sealed class ExpressionStatementSyntax : BaseStatementSyntax - { - public ExpressionStatementSyntax(BaseExpressionSyntax expression) - { - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.Expression = expression; - this.Expression.Parent = this; - } - - public BaseExpressionSyntax Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.Expression.Range.Start; - } - - TextPosition calculateEnd() - { - return this.Expression.Range.End; - } - } - } - } - - internal sealed class CommentStatementSyntax : BaseStatementSyntax - { - public CommentStatementSyntax(Token commentToken) - { - Debug.Assert(!commentToken.IsDefault(), "'commentToken' must not be null."); - Debug.Assert(commentToken.Kind == TokenKind.Comment, "'commentToken' must have a TokenKind of 'Comment'."); - - this.CommentToken = commentToken; - } - - public Token CommentToken { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.CommentToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.CommentToken.Range.End; - } - } - } - } - - internal abstract class BaseExpressionSyntax : BaseSyntaxNode - { - } - - internal sealed class UnaryOperatorExpressionSyntax : BaseExpressionSyntax - { - public UnaryOperatorExpressionSyntax(Token operatorToken, BaseExpressionSyntax expression) - { - Debug.Assert(!operatorToken.IsDefault(), "'operatorToken' must not be null."); - Debug.Assert(operatorToken.Kind == TokenKind.Minus, "'operatorToken' must have a TokenKind of 'Minus'."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - - this.OperatorToken = operatorToken; - this.Expression = expression; - this.Expression.Parent = this; - } - - public Token OperatorToken { get; private set; } - - public BaseExpressionSyntax Expression { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.OperatorToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.Expression.Range.End; - } - } - } - } - - internal sealed class BinaryOperatorExpressionSyntax : BaseExpressionSyntax - { - public BinaryOperatorExpressionSyntax(BaseExpressionSyntax left, Token operatorToken, BaseExpressionSyntax right) - { - Debug.Assert(!left.IsDefault(), "'left' must not be null."); - Debug.Assert(!operatorToken.IsDefault(), "'operatorToken' must not be null."); - Debug.Assert(operatorToken.Kind == TokenKind.Equal || operatorToken.Kind == TokenKind.NotEqual || operatorToken.Kind == TokenKind.Plus || operatorToken.Kind == TokenKind.Minus || operatorToken.Kind == TokenKind.Multiply || operatorToken.Kind == TokenKind.Divide || operatorToken.Kind == TokenKind.Colon || operatorToken.Kind == TokenKind.LessThan || operatorToken.Kind == TokenKind.GreaterThan || operatorToken.Kind == TokenKind.LessThanOrEqual || operatorToken.Kind == TokenKind.GreaterThanOrEqual || operatorToken.Kind == TokenKind.And || operatorToken.Kind == TokenKind.Or, "'operatorToken' must have a TokenKind of 'Equal,NotEqual,Plus,Minus,Multiply,Divide,Colon,LessThan,GreaterThan,LessThanOrEqual,GreaterThanOrEqual,And,Or'."); - Debug.Assert(!right.IsDefault(), "'right' must not be null."); - - this.Left = left; - this.Left.Parent = this; - this.OperatorToken = operatorToken; - this.Right = right; - this.Right.Parent = this; - } - - public BaseExpressionSyntax Left { get; private set; } - - public Token OperatorToken { get; private set; } - - public BaseExpressionSyntax Right { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Left; - yield return this.Right; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.Left.Range.Start; - } - - TextPosition calculateEnd() - { - return this.Right.Range.End; - } - } - } - } - - internal sealed class ObjectAccessExpressionSyntax : BaseExpressionSyntax - { - public ObjectAccessExpressionSyntax(BaseExpressionSyntax baseExpression, Token dotToken, Token identifierToken) - { - Debug.Assert(!baseExpression.IsDefault(), "'baseExpression' must not be null."); - Debug.Assert(!dotToken.IsDefault(), "'dotToken' must not be null."); - Debug.Assert(dotToken.Kind == TokenKind.Dot, "'dotToken' must have a TokenKind of 'Dot'."); - Debug.Assert(!identifierToken.IsDefault(), "'identifierToken' must not be null."); - Debug.Assert(identifierToken.Kind == TokenKind.Identifier, "'identifierToken' must have a TokenKind of 'Identifier'."); - - this.BaseExpression = baseExpression; - this.BaseExpression.Parent = this; - this.DotToken = dotToken; - this.IdentifierToken = identifierToken; - } - - public BaseExpressionSyntax BaseExpression { get; private set; } - - public Token DotToken { get; private set; } - - public Token IdentifierToken { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.BaseExpression; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.BaseExpression.Range.Start; - } - - TextPosition calculateEnd() - { - return this.IdentifierToken.Range.End; - } - } - } - } - - internal sealed class ArrayAccessExpressionSyntax : BaseExpressionSyntax - { - public ArrayAccessExpressionSyntax(BaseExpressionSyntax baseExpression, Token leftBracketToken, BaseExpressionSyntax indexExpression, Token rightBracketToken) - { - Debug.Assert(!baseExpression.IsDefault(), "'baseExpression' must not be null."); - Debug.Assert(!leftBracketToken.IsDefault(), "'leftBracketToken' must not be null."); - Debug.Assert(leftBracketToken.Kind == TokenKind.LeftBracket, "'leftBracketToken' must have a TokenKind of 'LeftBracket'."); - Debug.Assert(!indexExpression.IsDefault(), "'indexExpression' must not be null."); - Debug.Assert(!rightBracketToken.IsDefault(), "'rightBracketToken' must not be null."); - Debug.Assert(rightBracketToken.Kind == TokenKind.RightBracket, "'rightBracketToken' must have a TokenKind of 'RightBracket'."); - - this.BaseExpression = baseExpression; - this.BaseExpression.Parent = this; - this.LeftBracketToken = leftBracketToken; - this.IndexExpression = indexExpression; - this.IndexExpression.Parent = this; - this.RightBracketToken = rightBracketToken; - } - - public BaseExpressionSyntax BaseExpression { get; private set; } - - public Token LeftBracketToken { get; private set; } - - public BaseExpressionSyntax IndexExpression { get; private set; } - - public Token RightBracketToken { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.BaseExpression; - yield return this.IndexExpression; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.BaseExpression.Range.Start; - } - - TextPosition calculateEnd() - { - return this.RightBracketToken.Range.End; - } - } - } - } - - internal sealed class ArgumentSyntax : BaseExpressionSyntax - { - public ArgumentSyntax(BaseExpressionSyntax expression, Token commaTokenOpt) - { - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - if (!commaTokenOpt.IsDefault()) - { - Debug.Assert(commaTokenOpt.Kind == TokenKind.Comma, "'commaTokenOpt' must have a TokenKind of 'Comma'."); - } - - this.Expression = expression; - this.Expression.Parent = this; - this.CommaTokenOpt = commaTokenOpt; - } - - public BaseExpressionSyntax Expression { get; private set; } - - public Token CommaTokenOpt { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.Expression.Range.Start; - } - - TextPosition calculateEnd() - { - if (!this.CommaTokenOpt.IsDefault()) - { - return this.CommaTokenOpt.Range.End; - } - - return this.Expression.Range.End; - } - } - } - } - - internal sealed class InvocationExpressionSyntax : BaseExpressionSyntax - { - public InvocationExpressionSyntax(BaseExpressionSyntax baseExpression, Token leftParenToken, IReadOnlyList arguments, Token rightParenToken) - { - Debug.Assert(!baseExpression.IsDefault(), "'baseExpression' must not be null."); - Debug.Assert(!leftParenToken.IsDefault(), "'leftParenToken' must not be null."); - Debug.Assert(leftParenToken.Kind == TokenKind.LeftParen, "'leftParenToken' must have a TokenKind of 'LeftParen'."); - Debug.Assert(!arguments.IsDefault(), "'arguments' must not be null."); - Debug.Assert(!rightParenToken.IsDefault(), "'rightParenToken' must not be null."); - Debug.Assert(rightParenToken.Kind == TokenKind.RightParen, "'rightParenToken' must have a TokenKind of 'RightParen'."); - - this.BaseExpression = baseExpression; - this.BaseExpression.Parent = this; - this.LeftParenToken = leftParenToken; - this.Arguments = arguments; - foreach (var child in this.Arguments) - { - child.Parent = this; - } - - this.RightParenToken = rightParenToken; - } - - public BaseExpressionSyntax BaseExpression { get; private set; } - - public Token LeftParenToken { get; private set; } - - public IReadOnlyList Arguments { get; private set; } - - public Token RightParenToken { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.BaseExpression; - foreach (var child in this.Arguments) - { - yield return child; - } - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.BaseExpression.Range.Start; - } - - TextPosition calculateEnd() - { - return this.RightParenToken.Range.End; - } - } - } - } - - internal sealed class ParenthesisExpressionSyntax : BaseExpressionSyntax - { - public ParenthesisExpressionSyntax(Token leftParenToken, BaseExpressionSyntax expression, Token rightParenToken) - { - Debug.Assert(!leftParenToken.IsDefault(), "'leftParenToken' must not be null."); - Debug.Assert(leftParenToken.Kind == TokenKind.LeftParen, "'leftParenToken' must have a TokenKind of 'LeftParen'."); - Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); - Debug.Assert(!rightParenToken.IsDefault(), "'rightParenToken' must not be null."); - Debug.Assert(rightParenToken.Kind == TokenKind.RightParen, "'rightParenToken' must have a TokenKind of 'RightParen'."); - - this.LeftParenToken = leftParenToken; - this.Expression = expression; - this.Expression.Parent = this; - this.RightParenToken = rightParenToken; - } - - public Token LeftParenToken { get; private set; } - - public BaseExpressionSyntax Expression { get; private set; } - - public Token RightParenToken { get; private set; } - - public override IEnumerable Children - { - get - { - yield return this.Expression; - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.LeftParenToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.RightParenToken.Range.End; - } - } - } - } - - internal sealed class IdentifierExpressionSyntax : BaseExpressionSyntax - { - public IdentifierExpressionSyntax(Token identifierToken) - { - Debug.Assert(!identifierToken.IsDefault(), "'identifierToken' must not be null."); - Debug.Assert(identifierToken.Kind == TokenKind.Identifier, "'identifierToken' must have a TokenKind of 'Identifier'."); - - this.IdentifierToken = identifierToken; - } - - public Token IdentifierToken { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.IdentifierToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.IdentifierToken.Range.End; - } - } - } - } - - internal sealed class StringLiteralExpressionSyntax : BaseExpressionSyntax - { - public StringLiteralExpressionSyntax(Token stringToken) - { - Debug.Assert(!stringToken.IsDefault(), "'stringToken' must not be null."); - Debug.Assert(stringToken.Kind == TokenKind.StringLiteral, "'stringToken' must have a TokenKind of 'StringLiteral'."); - - this.StringToken = stringToken; - } - - public Token StringToken { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.StringToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.StringToken.Range.End; - } - } - } - } - - internal sealed class NumberLiteralExpressionSyntax : BaseExpressionSyntax - { - public NumberLiteralExpressionSyntax(Token numberToken) - { - Debug.Assert(!numberToken.IsDefault(), "'numberToken' must not be null."); - Debug.Assert(numberToken.Kind == TokenKind.NumberLiteral, "'numberToken' must have a TokenKind of 'NumberLiteral'."); - - this.NumberToken = numberToken; - } - - public Token NumberToken { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.NumberToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.NumberToken.Range.End; - } - } - } - } - - internal sealed class UnrecognizedExpressionSyntax : BaseExpressionSyntax - { - public UnrecognizedExpressionSyntax(Token unrecognizedToken) - { - Debug.Assert(!unrecognizedToken.IsDefault(), "'unrecognizedToken' must not be null."); - - this.UnrecognizedToken = unrecognizedToken; - } - - public Token UnrecognizedToken { get; private set; } - - public override IEnumerable Children - { - get - { - return Enumerable.Empty(); - } - } - - public override TextRange Range - { - get - { - return (calculateStart(), calculateEnd()); - - TextPosition calculateStart() - { - return this.UnrecognizedToken.Range.Start; - } - - TextPosition calculateEnd() - { - return this.UnrecognizedToken.Range.End; - } - } - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Compiler.Parsing +{ + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.Linq; + using SmallBasic.Compiler.Scanning; + using SmallBasic.Utilities; + + public abstract class BaseSyntaxNodeVisitor + { + private protected void Visit(BaseSyntaxNode node) + { + switch (node) + { + case SubModuleStatementSyntax subModuleStatement: + this.VisitSubModuleStatement(subModuleStatement); + break; + case ParameterSyntax parameter: + this.VisitParameter(parameter); + break; + case FunctionDeclarationSyntax functionDeclaration: + this.VisitFunctionDeclaration(functionDeclaration); + break; + case ReturnStatementSyntax returnStatement: + this.VisitReturnStatement(returnStatement); + break; + case ImportStatementSyntax importStatement: + this.VisitImportStatement(importStatement); + break; + case StatementBlockSyntax statementBlock: + this.VisitStatementBlock(statementBlock); + break; + case IfPartSyntax ifPart: + this.VisitIfPart(ifPart); + break; + case ElseIfPartSyntax elseIfPart: + this.VisitElseIfPart(elseIfPart); + break; + case ElsePartSyntax elsePart: + this.VisitElsePart(elsePart); + break; + case IfStatementSyntax ifStatement: + this.VisitIfStatement(ifStatement); + break; + case WhileStatementSyntax whileStatement: + this.VisitWhileStatement(whileStatement); + break; + case ForStepClauseSyntax forStepClause: + this.VisitForStepClause(forStepClause); + break; + case ForStatementSyntax forStatement: + this.VisitForStatement(forStatement); + break; + case ForEachStatementSyntax forEachStatement: + this.VisitForEachStatement(forEachStatement); + break; + case CaseClauseSyntax caseClause: + this.VisitCaseClause(caseClause); + break; + case SelectStatementSyntax selectStatement: + this.VisitSelectStatement(selectStatement); + break; + case CatchClauseSyntax catchClause: + this.VisitCatchClause(catchClause); + break; + case FinallyClauseSyntax finallyClause: + this.VisitFinallyClause(finallyClause); + break; + case TryStatementSyntax tryStatement: + this.VisitTryStatement(tryStatement); + break; + case LabelStatementSyntax labelStatement: + this.VisitLabelStatement(labelStatement); + break; + case GoToStatementSyntax goToStatement: + this.VisitGoToStatement(goToStatement); + break; + case UnrecognizedStatementSyntax unrecognizedStatement: + this.VisitUnrecognizedStatement(unrecognizedStatement); + break; + case ExpressionStatementSyntax expressionStatement: + this.VisitExpressionStatement(expressionStatement); + break; + case CommentStatementSyntax commentStatement: + this.VisitCommentStatement(commentStatement); + break; + case UnaryOperatorExpressionSyntax unaryOperatorExpression: + this.VisitUnaryOperatorExpression(unaryOperatorExpression); + break; + case BinaryOperatorExpressionSyntax binaryOperatorExpression: + this.VisitBinaryOperatorExpression(binaryOperatorExpression); + break; + case ObjectAccessExpressionSyntax objectAccessExpression: + this.VisitObjectAccessExpression(objectAccessExpression); + break; + case ArrayAccessExpressionSyntax arrayAccessExpression: + this.VisitArrayAccessExpression(arrayAccessExpression); + break; + case ArgumentSyntax argument: + this.VisitArgument(argument); + break; + case InvocationExpressionSyntax invocationExpression: + this.VisitInvocationExpression(invocationExpression); + break; + case ParenthesisExpressionSyntax parenthesisExpression: + this.VisitParenthesisExpression(parenthesisExpression); + break; + case IdentifierExpressionSyntax identifierExpression: + this.VisitIdentifierExpression(identifierExpression); + break; + case StringLiteralExpressionSyntax stringLiteralExpression: + this.VisitStringLiteralExpression(stringLiteralExpression); + break; + case NumberLiteralExpressionSyntax numberLiteralExpression: + this.VisitNumberLiteralExpression(numberLiteralExpression); + break; + case UnrecognizedExpressionSyntax unrecognizedExpression: + this.VisitUnrecognizedExpression(unrecognizedExpression); + break; + default: + throw ExceptionUtilities.UnexpectedValue(node); + } + } + + private protected virtual void VisitSubModuleStatement(SubModuleStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitParameter(ParameterSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitFunctionDeclaration(FunctionDeclarationSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitReturnStatement(ReturnStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitImportStatement(ImportStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitStatementBlock(StatementBlockSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitIfPart(IfPartSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitElseIfPart(ElseIfPartSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitElsePart(ElsePartSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitIfStatement(IfStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitWhileStatement(WhileStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitForStepClause(ForStepClauseSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitForStatement(ForStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitForEachStatement(ForEachStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitCaseClause(CaseClauseSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitSelectStatement(SelectStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitCatchClause(CatchClauseSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitFinallyClause(FinallyClauseSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitTryStatement(TryStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitLabelStatement(LabelStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitGoToStatement(GoToStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitUnrecognizedStatement(UnrecognizedStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitExpressionStatement(ExpressionStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitCommentStatement(CommentStatementSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitUnaryOperatorExpression(UnaryOperatorExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitBinaryOperatorExpression(BinaryOperatorExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitObjectAccessExpression(ObjectAccessExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitArrayAccessExpression(ArrayAccessExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitArgument(ArgumentSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitInvocationExpression(InvocationExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitParenthesisExpression(ParenthesisExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitIdentifierExpression(IdentifierExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitStringLiteralExpression(StringLiteralExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitNumberLiteralExpression(NumberLiteralExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private protected virtual void VisitUnrecognizedExpression(UnrecognizedExpressionSyntax node) + { + this.DefaultVisit(node); + } + + private void DefaultVisit(BaseSyntaxNode node) + { + foreach (var child in node.Children) + { + this.Visit(child); + } + } + } + + internal abstract class BaseStatementSyntax : BaseSyntaxNode + { + } + + internal sealed class SubModuleStatementSyntax : BaseStatementSyntax + { + public SubModuleStatementSyntax(Token subToken, Token nameToken, StatementBlockSyntax body, Token endSubToken) + { + Debug.Assert(!subToken.IsDefault(), "'subToken' must not be null."); + Debug.Assert(subToken.Kind == TokenKind.Sub, "'subToken' must have a TokenKind of 'Sub'."); + Debug.Assert(!nameToken.IsDefault(), "'nameToken' must not be null."); + Debug.Assert(nameToken.Kind == TokenKind.Identifier, "'nameToken' must have a TokenKind of 'Identifier'."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + Debug.Assert(!endSubToken.IsDefault(), "'endSubToken' must not be null."); + Debug.Assert(endSubToken.Kind == TokenKind.EndSub, "'endSubToken' must have a TokenKind of 'EndSub'."); + + this.SubToken = subToken; + this.NameToken = nameToken; + this.Body = body; + this.Body.Parent = this; + this.EndSubToken = endSubToken; + } + + public Token SubToken { get; private set; } + + public Token NameToken { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public Token EndSubToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.SubToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.EndSubToken.Range.End; + } + } + } + } + + internal sealed class ParameterSyntax : BaseSyntaxNode + { + public ParameterSyntax(Token identifierToken, Token commaTokenOpt) + { + Debug.Assert(!identifierToken.IsDefault(), "'identifierToken' must not be null."); + Debug.Assert(identifierToken.Kind == TokenKind.Identifier, "'identifierToken' must have a TokenKind of 'Identifier'."); + if (!commaTokenOpt.IsDefault()) + { + Debug.Assert(commaTokenOpt.Kind == TokenKind.Comma, "'commaTokenOpt' must have a TokenKind of 'Comma'."); + } + + this.IdentifierToken = identifierToken; + this.CommaTokenOpt = commaTokenOpt; + } + + public Token IdentifierToken { get; private set; } + + public Token CommaTokenOpt { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.IdentifierToken.Range.Start; + } + + TextPosition calculateEnd() + { + if (!this.CommaTokenOpt.IsDefault()) + { + return this.CommaTokenOpt.Range.End; + } + + return this.IdentifierToken.Range.End; + } + } + } + } + + internal sealed class FunctionDeclarationSyntax : BaseStatementSyntax + { + public FunctionDeclarationSyntax(Token functionToken, Token nameToken, Token leftParenTokenOpt, IReadOnlyList parameters, Token rightParenTokenOpt, StatementBlockSyntax body, Token endFunctionToken) + { + Debug.Assert(!functionToken.IsDefault(), "'functionToken' must not be null."); + Debug.Assert(functionToken.Kind == TokenKind.Function || functionToken.Kind == TokenKind.Fn || functionToken.Kind == TokenKind.Sub, "'functionToken' must have a TokenKind of 'Function,Fn,Sub'."); + Debug.Assert(!nameToken.IsDefault(), "'nameToken' must not be null."); + Debug.Assert(nameToken.Kind == TokenKind.Identifier, "'nameToken' must have a TokenKind of 'Identifier'."); + if (!leftParenTokenOpt.IsDefault()) + { + Debug.Assert(leftParenTokenOpt.Kind == TokenKind.LeftParen, "'leftParenTokenOpt' must have a TokenKind of 'LeftParen'."); + } + + Debug.Assert(!parameters.IsDefault(), "'parameters' must not be null."); + if (!rightParenTokenOpt.IsDefault()) + { + Debug.Assert(rightParenTokenOpt.Kind == TokenKind.RightParen, "'rightParenTokenOpt' must have a TokenKind of 'RightParen'."); + } + + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + Debug.Assert(!endFunctionToken.IsDefault(), "'endFunctionToken' must not be null."); + Debug.Assert(endFunctionToken.Kind == TokenKind.EndFunction || endFunctionToken.Kind == TokenKind.EndFn || endFunctionToken.Kind == TokenKind.EndSub, "'endFunctionToken' must have a TokenKind of 'EndFunction,EndFn,EndSub'."); + + this.FunctionToken = functionToken; + this.NameToken = nameToken; + this.LeftParenTokenOpt = leftParenTokenOpt; + this.Parameters = parameters; + foreach (var child in this.Parameters) + { + child.Parent = this; + } + + this.RightParenTokenOpt = rightParenTokenOpt; + this.Body = body; + this.Body.Parent = this; + this.EndFunctionToken = endFunctionToken; + } + + public Token FunctionToken { get; private set; } + + public Token NameToken { get; private set; } + + public Token LeftParenTokenOpt { get; private set; } + + public IReadOnlyList Parameters { get; private set; } + + public Token RightParenTokenOpt { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public Token EndFunctionToken { get; private set; } + + public override IEnumerable Children + { + get + { + foreach (var child in this.Parameters) + { + yield return child; + } + + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.FunctionToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.EndFunctionToken.Range.End; + } + } + } + } + + internal sealed class ReturnStatementSyntax : BaseStatementSyntax + { + public ReturnStatementSyntax(Token returnToken, BaseExpressionSyntax expressionOpt) + { + Debug.Assert(!returnToken.IsDefault(), "'returnToken' must not be null."); + Debug.Assert(returnToken.Kind == TokenKind.Return, "'returnToken' must have a TokenKind of 'Return'."); + + this.ReturnToken = returnToken; + this.ExpressionOpt = expressionOpt; + if (!this.ExpressionOpt.IsDefault()) + { + this.ExpressionOpt.Parent = this; + } + } + + public Token ReturnToken { get; private set; } + + public BaseExpressionSyntax ExpressionOpt { get; private set; } + + public override IEnumerable Children + { + get + { + if (!this.ExpressionOpt.IsDefault()) + { + yield return this.ExpressionOpt; + } + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.ReturnToken.Range.Start; + } + + TextPosition calculateEnd() + { + if (!this.ExpressionOpt.IsDefault()) + { + return this.ExpressionOpt.Range.End; + } + + return this.ReturnToken.Range.End; + } + } + } + } + + internal sealed class ImportStatementSyntax : BaseStatementSyntax + { + public ImportStatementSyntax(Token importToken, Token pathToken) + { + Debug.Assert(!importToken.IsDefault(), "'importToken' must not be null."); + Debug.Assert(importToken.Kind == TokenKind.Import, "'importToken' must have a TokenKind of 'Import'."); + Debug.Assert(!pathToken.IsDefault(), "'pathToken' must not be null."); + Debug.Assert(pathToken.Kind == TokenKind.StringLiteral, "'pathToken' must have a TokenKind of 'StringLiteral'."); + + this.ImportToken = importToken; + this.PathToken = pathToken; + } + + public Token ImportToken { get; private set; } + + public Token PathToken { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.ImportToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.PathToken.Range.End; + } + } + } + } + + internal sealed class StatementBlockSyntax : BaseStatementSyntax + { + public StatementBlockSyntax(IReadOnlyList body) + { + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.Body = body; + foreach (var child in this.Body) + { + child.Parent = this; + } + } + + public IReadOnlyList Body { get; private set; } + + public override IEnumerable Children + { + get + { + foreach (var child in this.Body) + { + yield return child; + } + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + var bodyChild = this.Body.FirstOrDefault(); + if (!bodyChild.IsDefault()) + { + return bodyChild.Range.Start; + } + + return (0, 0); + } + + TextPosition calculateEnd() + { + var bodyChild = this.Body.LastOrDefault(); + if (!bodyChild.IsDefault()) + { + return bodyChild.Range.End; + } + + return (0, 0); + } + } + } + } + + internal sealed class IfPartSyntax : BaseSyntaxNode + { + public IfPartSyntax(Token ifToken, BaseExpressionSyntax condition, Token thenToken, StatementBlockSyntax body) + { + Debug.Assert(!ifToken.IsDefault(), "'ifToken' must not be null."); + Debug.Assert(ifToken.Kind == TokenKind.If, "'ifToken' must have a TokenKind of 'If'."); + Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); + Debug.Assert(!thenToken.IsDefault(), "'thenToken' must not be null."); + Debug.Assert(thenToken.Kind == TokenKind.Then, "'thenToken' must have a TokenKind of 'Then'."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.IfToken = ifToken; + this.Condition = condition; + this.Condition.Parent = this; + this.ThenToken = thenToken; + this.Body = body; + this.Body.Parent = this; + } + + public Token IfToken { get; private set; } + + public BaseExpressionSyntax Condition { get; private set; } + + public Token ThenToken { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Condition; + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.IfToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Body.Range.End; + } + } + } + } + + internal sealed class ElseIfPartSyntax : BaseSyntaxNode + { + public ElseIfPartSyntax(Token elseIfToken, BaseExpressionSyntax condition, Token thenToken, StatementBlockSyntax body) + { + Debug.Assert(!elseIfToken.IsDefault(), "'elseIfToken' must not be null."); + Debug.Assert(elseIfToken.Kind == TokenKind.ElseIf, "'elseIfToken' must have a TokenKind of 'ElseIf'."); + Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); + Debug.Assert(!thenToken.IsDefault(), "'thenToken' must not be null."); + Debug.Assert(thenToken.Kind == TokenKind.Then, "'thenToken' must have a TokenKind of 'Then'."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.ElseIfToken = elseIfToken; + this.Condition = condition; + this.Condition.Parent = this; + this.ThenToken = thenToken; + this.Body = body; + this.Body.Parent = this; + } + + public Token ElseIfToken { get; private set; } + + public BaseExpressionSyntax Condition { get; private set; } + + public Token ThenToken { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Condition; + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.ElseIfToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Body.Range.End; + } + } + } + } + + internal sealed class ElsePartSyntax : BaseSyntaxNode + { + public ElsePartSyntax(Token elseToken, StatementBlockSyntax body) + { + Debug.Assert(!elseToken.IsDefault(), "'elseToken' must not be null."); + Debug.Assert(elseToken.Kind == TokenKind.Else, "'elseToken' must have a TokenKind of 'Else'."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.ElseToken = elseToken; + this.Body = body; + this.Body.Parent = this; + } + + public Token ElseToken { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.ElseToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Body.Range.End; + } + } + } + } + + internal sealed class IfStatementSyntax : BaseStatementSyntax + { + public IfStatementSyntax(IfPartSyntax ifPart, IReadOnlyList elseIfParts, ElsePartSyntax elsePartOpt, Token endIfToken) + { + Debug.Assert(!ifPart.IsDefault(), "'ifPart' must not be null."); + Debug.Assert(!elseIfParts.IsDefault(), "'elseIfParts' must not be null."); + Debug.Assert(!endIfToken.IsDefault(), "'endIfToken' must not be null."); + Debug.Assert(endIfToken.Kind == TokenKind.EndIf, "'endIfToken' must have a TokenKind of 'EndIf'."); + + this.IfPart = ifPart; + this.IfPart.Parent = this; + this.ElseIfParts = elseIfParts; + foreach (var child in this.ElseIfParts) + { + child.Parent = this; + } + + this.ElsePartOpt = elsePartOpt; + if (!this.ElsePartOpt.IsDefault()) + { + this.ElsePartOpt.Parent = this; + } + + this.EndIfToken = endIfToken; + } + + public IfPartSyntax IfPart { get; private set; } + + public IReadOnlyList ElseIfParts { get; private set; } + + public ElsePartSyntax ElsePartOpt { get; private set; } + + public Token EndIfToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.IfPart; + foreach (var child in this.ElseIfParts) + { + yield return child; + } + + if (!this.ElsePartOpt.IsDefault()) + { + yield return this.ElsePartOpt; + } + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.IfPart.Range.Start; + } + + TextPosition calculateEnd() + { + return this.EndIfToken.Range.End; + } + } + } + } + + internal sealed class WhileStatementSyntax : BaseStatementSyntax + { + public WhileStatementSyntax(Token whileToken, BaseExpressionSyntax condition, StatementBlockSyntax body, Token endWhileToken) + { + Debug.Assert(!whileToken.IsDefault(), "'whileToken' must not be null."); + Debug.Assert(whileToken.Kind == TokenKind.While, "'whileToken' must have a TokenKind of 'While'."); + Debug.Assert(!condition.IsDefault(), "'condition' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + Debug.Assert(!endWhileToken.IsDefault(), "'endWhileToken' must not be null."); + Debug.Assert(endWhileToken.Kind == TokenKind.EndWhile, "'endWhileToken' must have a TokenKind of 'EndWhile'."); + + this.WhileToken = whileToken; + this.Condition = condition; + this.Condition.Parent = this; + this.Body = body; + this.Body.Parent = this; + this.EndWhileToken = endWhileToken; + } + + public Token WhileToken { get; private set; } + + public BaseExpressionSyntax Condition { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public Token EndWhileToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Condition; + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.WhileToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.EndWhileToken.Range.End; + } + } + } + } + + internal sealed class ForStepClauseSyntax : BaseSyntaxNode + { + public ForStepClauseSyntax(Token stepToken, BaseExpressionSyntax expression) + { + Debug.Assert(!stepToken.IsDefault(), "'stepToken' must not be null."); + Debug.Assert(stepToken.Kind == TokenKind.Step, "'stepToken' must have a TokenKind of 'Step'."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.StepToken = stepToken; + this.Expression = expression; + this.Expression.Parent = this; + } + + public Token StepToken { get; private set; } + + public BaseExpressionSyntax Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.StepToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Expression.Range.End; + } + } + } + } + + internal sealed class ForStatementSyntax : BaseStatementSyntax + { + public ForStatementSyntax(Token forToken, Token identifierToken, Token equalToken, BaseExpressionSyntax fromExpression, Token toToken, BaseExpressionSyntax toExpression, ForStepClauseSyntax stepClauseOpt, StatementBlockSyntax body, Token endForToken) + { + Debug.Assert(!forToken.IsDefault(), "'forToken' must not be null."); + Debug.Assert(forToken.Kind == TokenKind.For, "'forToken' must have a TokenKind of 'For'."); + Debug.Assert(!identifierToken.IsDefault(), "'identifierToken' must not be null."); + Debug.Assert(identifierToken.Kind == TokenKind.Identifier, "'identifierToken' must have a TokenKind of 'Identifier'."); + Debug.Assert(!equalToken.IsDefault(), "'equalToken' must not be null."); + Debug.Assert(equalToken.Kind == TokenKind.Equal, "'equalToken' must have a TokenKind of 'Equal'."); + Debug.Assert(!fromExpression.IsDefault(), "'fromExpression' must not be null."); + Debug.Assert(!toToken.IsDefault(), "'toToken' must not be null."); + Debug.Assert(toToken.Kind == TokenKind.To, "'toToken' must have a TokenKind of 'To'."); + Debug.Assert(!toExpression.IsDefault(), "'toExpression' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + Debug.Assert(!endForToken.IsDefault(), "'endForToken' must not be null."); + Debug.Assert(endForToken.Kind == TokenKind.EndFor, "'endForToken' must have a TokenKind of 'EndFor'."); + + this.ForToken = forToken; + this.IdentifierToken = identifierToken; + this.EqualToken = equalToken; + this.FromExpression = fromExpression; + this.FromExpression.Parent = this; + this.ToToken = toToken; + this.ToExpression = toExpression; + this.ToExpression.Parent = this; + this.StepClauseOpt = stepClauseOpt; + if (!this.StepClauseOpt.IsDefault()) + { + this.StepClauseOpt.Parent = this; + } + + this.Body = body; + this.Body.Parent = this; + this.EndForToken = endForToken; + } + + public Token ForToken { get; private set; } + + public Token IdentifierToken { get; private set; } + + public Token EqualToken { get; private set; } + + public BaseExpressionSyntax FromExpression { get; private set; } + + public Token ToToken { get; private set; } + + public BaseExpressionSyntax ToExpression { get; private set; } + + public ForStepClauseSyntax StepClauseOpt { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public Token EndForToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.FromExpression; + yield return this.ToExpression; + if (!this.StepClauseOpt.IsDefault()) + { + yield return this.StepClauseOpt; + } + + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.ForToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.EndForToken.Range.End; + } + } + } + } + + internal sealed class ForEachStatementSyntax : BaseStatementSyntax + { + public ForEachStatementSyntax(Token forEachToken, Token identifierToken, Token inToken, BaseExpressionSyntax collectionExpression, StatementBlockSyntax body, Token endForToken) + { + Debug.Assert(!forEachToken.IsDefault(), "'forEachToken' must not be null."); + Debug.Assert(forEachToken.Kind == TokenKind.ForEach, "'forEachToken' must have a TokenKind of 'ForEach'."); + Debug.Assert(!identifierToken.IsDefault(), "'identifierToken' must not be null."); + Debug.Assert(identifierToken.Kind == TokenKind.Identifier, "'identifierToken' must have a TokenKind of 'Identifier'."); + Debug.Assert(!inToken.IsDefault(), "'inToken' must not be null."); + Debug.Assert(inToken.Kind == TokenKind.In, "'inToken' must have a TokenKind of 'In'."); + Debug.Assert(!collectionExpression.IsDefault(), "'collectionExpression' must not be null."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + Debug.Assert(!endForToken.IsDefault(), "'endForToken' must not be null."); + Debug.Assert(endForToken.Kind == TokenKind.EndFor, "'endForToken' must have a TokenKind of 'EndFor'."); + + this.ForEachToken = forEachToken; + this.IdentifierToken = identifierToken; + this.InToken = inToken; + this.CollectionExpression = collectionExpression; + this.CollectionExpression.Parent = this; + this.Body = body; + this.Body.Parent = this; + this.EndForToken = endForToken; + } + + public Token ForEachToken { get; private set; } + + public Token IdentifierToken { get; private set; } + + public Token InToken { get; private set; } + + public BaseExpressionSyntax CollectionExpression { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public Token EndForToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.CollectionExpression; + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.ForEachToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.EndForToken.Range.End; + } + } + } + } + + internal sealed class CaseClauseSyntax : BaseSyntaxNode + { + public CaseClauseSyntax(Token caseToken, BaseExpressionSyntax valueExpressionOpt, StatementBlockSyntax body) + { + Debug.Assert(!caseToken.IsDefault(), "'caseToken' must not be null."); + Debug.Assert(caseToken.Kind == TokenKind.Case || caseToken.Kind == TokenKind.Else, "'caseToken' must have a TokenKind of 'Case,Else'."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.CaseToken = caseToken; + this.ValueExpressionOpt = valueExpressionOpt; + if (!this.ValueExpressionOpt.IsDefault()) + { + this.ValueExpressionOpt.Parent = this; + } + + this.Body = body; + this.Body.Parent = this; + } + + public Token CaseToken { get; private set; } + + public BaseExpressionSyntax ValueExpressionOpt { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public override IEnumerable Children + { + get + { + if (!this.ValueExpressionOpt.IsDefault()) + { + yield return this.ValueExpressionOpt; + } + + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.CaseToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Body.Range.End; + } + } + } + } + + internal sealed class SelectStatementSyntax : BaseStatementSyntax + { + public SelectStatementSyntax(Token selectToken, BaseExpressionSyntax expression, IReadOnlyList cases, Token endSelectToken) + { + Debug.Assert(!selectToken.IsDefault(), "'selectToken' must not be null."); + Debug.Assert(selectToken.Kind == TokenKind.Select, "'selectToken' must have a TokenKind of 'Select'."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + Debug.Assert(!cases.IsDefault(), "'cases' must not be null."); + Debug.Assert(!endSelectToken.IsDefault(), "'endSelectToken' must not be null."); + Debug.Assert(endSelectToken.Kind == TokenKind.EndSelect, "'endSelectToken' must have a TokenKind of 'EndSelect'."); + + this.SelectToken = selectToken; + this.Expression = expression; + this.Expression.Parent = this; + this.Cases = cases; + foreach (var child in this.Cases) + { + child.Parent = this; + } + + this.EndSelectToken = endSelectToken; + } + + public Token SelectToken { get; private set; } + + public BaseExpressionSyntax Expression { get; private set; } + + public IReadOnlyList Cases { get; private set; } + + public Token EndSelectToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + foreach (var child in this.Cases) + { + yield return child; + } + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.SelectToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.EndSelectToken.Range.End; + } + } + } + } + + internal sealed class CatchClauseSyntax : BaseSyntaxNode + { + public CatchClauseSyntax(Token catchToken, Token variableTokenOpt, StatementBlockSyntax body) + { + Debug.Assert(!catchToken.IsDefault(), "'catchToken' must not be null."); + Debug.Assert(catchToken.Kind == TokenKind.Catch, "'catchToken' must have a TokenKind of 'Catch'."); + if (!variableTokenOpt.IsDefault()) + { + Debug.Assert(variableTokenOpt.Kind == TokenKind.Identifier, "'variableTokenOpt' must have a TokenKind of 'Identifier'."); + } + + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.CatchToken = catchToken; + this.VariableTokenOpt = variableTokenOpt; + this.Body = body; + this.Body.Parent = this; + } + + public Token CatchToken { get; private set; } + + public Token VariableTokenOpt { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.CatchToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Body.Range.End; + } + } + } + } + + internal sealed class FinallyClauseSyntax : BaseSyntaxNode + { + public FinallyClauseSyntax(Token finallyToken, StatementBlockSyntax body) + { + Debug.Assert(!finallyToken.IsDefault(), "'finallyToken' must not be null."); + Debug.Assert(finallyToken.Kind == TokenKind.Finally, "'finallyToken' must have a TokenKind of 'Finally'."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + + this.FinallyToken = finallyToken; + this.Body = body; + this.Body.Parent = this; + } + + public Token FinallyToken { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.FinallyToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Body.Range.End; + } + } + } + } + + internal sealed class TryStatementSyntax : BaseStatementSyntax + { + public TryStatementSyntax(Token tryToken, StatementBlockSyntax body, CatchClauseSyntax catchClauseOpt, FinallyClauseSyntax finallyClauseOpt, Token endTryToken) + { + Debug.Assert(!tryToken.IsDefault(), "'tryToken' must not be null."); + Debug.Assert(tryToken.Kind == TokenKind.Try, "'tryToken' must have a TokenKind of 'Try'."); + Debug.Assert(!body.IsDefault(), "'body' must not be null."); + Debug.Assert(!endTryToken.IsDefault(), "'endTryToken' must not be null."); + Debug.Assert(endTryToken.Kind == TokenKind.EndTry, "'endTryToken' must have a TokenKind of 'EndTry'."); + + this.TryToken = tryToken; + this.Body = body; + this.Body.Parent = this; + this.CatchClauseOpt = catchClauseOpt; + if (!this.CatchClauseOpt.IsDefault()) + { + this.CatchClauseOpt.Parent = this; + } + + this.FinallyClauseOpt = finallyClauseOpt; + if (!this.FinallyClauseOpt.IsDefault()) + { + this.FinallyClauseOpt.Parent = this; + } + + this.EndTryToken = endTryToken; + } + + public Token TryToken { get; private set; } + + public StatementBlockSyntax Body { get; private set; } + + public CatchClauseSyntax CatchClauseOpt { get; private set; } + + public FinallyClauseSyntax FinallyClauseOpt { get; private set; } + + public Token EndTryToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Body; + if (!this.CatchClauseOpt.IsDefault()) + { + yield return this.CatchClauseOpt; + } + + if (!this.FinallyClauseOpt.IsDefault()) + { + yield return this.FinallyClauseOpt; + } + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.TryToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.EndTryToken.Range.End; + } + } + } + } + + internal sealed class LabelStatementSyntax : BaseStatementSyntax + { + public LabelStatementSyntax(Token labelToken, Token colonToken) + { + Debug.Assert(!labelToken.IsDefault(), "'labelToken' must not be null."); + Debug.Assert(labelToken.Kind == TokenKind.Identifier, "'labelToken' must have a TokenKind of 'Identifier'."); + Debug.Assert(!colonToken.IsDefault(), "'colonToken' must not be null."); + Debug.Assert(colonToken.Kind == TokenKind.Colon, "'colonToken' must have a TokenKind of 'Colon'."); + + this.LabelToken = labelToken; + this.ColonToken = colonToken; + } + + public Token LabelToken { get; private set; } + + public Token ColonToken { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.LabelToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.ColonToken.Range.End; + } + } + } + } + + internal sealed class GoToStatementSyntax : BaseStatementSyntax + { + public GoToStatementSyntax(Token goToToken, Token labelToken) + { + Debug.Assert(!goToToken.IsDefault(), "'goToToken' must not be null."); + Debug.Assert(goToToken.Kind == TokenKind.GoTo, "'goToToken' must have a TokenKind of 'GoTo'."); + Debug.Assert(!labelToken.IsDefault(), "'labelToken' must not be null."); + Debug.Assert(labelToken.Kind == TokenKind.Identifier, "'labelToken' must have a TokenKind of 'Identifier'."); + + this.GoToToken = goToToken; + this.LabelToken = labelToken; + } + + public Token GoToToken { get; private set; } + + public Token LabelToken { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.GoToToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.LabelToken.Range.End; + } + } + } + } + + internal sealed class UnrecognizedStatementSyntax : BaseStatementSyntax + { + public UnrecognizedStatementSyntax(Token unrecognizedToken) + { + Debug.Assert(!unrecognizedToken.IsDefault(), "'unrecognizedToken' must not be null."); + + this.UnrecognizedToken = unrecognizedToken; + } + + public Token UnrecognizedToken { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.UnrecognizedToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.UnrecognizedToken.Range.End; + } + } + } + } + + internal sealed class ExpressionStatementSyntax : BaseStatementSyntax + { + public ExpressionStatementSyntax(BaseExpressionSyntax expression) + { + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.Expression = expression; + this.Expression.Parent = this; + } + + public BaseExpressionSyntax Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.Expression.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Expression.Range.End; + } + } + } + } + + internal sealed class CommentStatementSyntax : BaseStatementSyntax + { + public CommentStatementSyntax(Token commentToken) + { + Debug.Assert(!commentToken.IsDefault(), "'commentToken' must not be null."); + Debug.Assert(commentToken.Kind == TokenKind.Comment, "'commentToken' must have a TokenKind of 'Comment'."); + + this.CommentToken = commentToken; + } + + public Token CommentToken { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.CommentToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.CommentToken.Range.End; + } + } + } + } + + internal abstract class BaseExpressionSyntax : BaseSyntaxNode + { + } + + internal sealed class UnaryOperatorExpressionSyntax : BaseExpressionSyntax + { + public UnaryOperatorExpressionSyntax(Token operatorToken, BaseExpressionSyntax expression) + { + Debug.Assert(!operatorToken.IsDefault(), "'operatorToken' must not be null."); + Debug.Assert(operatorToken.Kind == TokenKind.Minus, "'operatorToken' must have a TokenKind of 'Minus'."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + + this.OperatorToken = operatorToken; + this.Expression = expression; + this.Expression.Parent = this; + } + + public Token OperatorToken { get; private set; } + + public BaseExpressionSyntax Expression { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.OperatorToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Expression.Range.End; + } + } + } + } + + internal sealed class BinaryOperatorExpressionSyntax : BaseExpressionSyntax + { + public BinaryOperatorExpressionSyntax(BaseExpressionSyntax left, Token operatorToken, BaseExpressionSyntax right) + { + Debug.Assert(!left.IsDefault(), "'left' must not be null."); + Debug.Assert(!operatorToken.IsDefault(), "'operatorToken' must not be null."); + Debug.Assert(operatorToken.Kind == TokenKind.Equal || operatorToken.Kind == TokenKind.NotEqual || operatorToken.Kind == TokenKind.Plus || operatorToken.Kind == TokenKind.Minus || operatorToken.Kind == TokenKind.Multiply || operatorToken.Kind == TokenKind.Divide || operatorToken.Kind == TokenKind.Colon || operatorToken.Kind == TokenKind.LessThan || operatorToken.Kind == TokenKind.GreaterThan || operatorToken.Kind == TokenKind.LessThanOrEqual || operatorToken.Kind == TokenKind.GreaterThanOrEqual || operatorToken.Kind == TokenKind.And || operatorToken.Kind == TokenKind.Or, "'operatorToken' must have a TokenKind of 'Equal,NotEqual,Plus,Minus,Multiply,Divide,Colon,LessThan,GreaterThan,LessThanOrEqual,GreaterThanOrEqual,And,Or'."); + Debug.Assert(!right.IsDefault(), "'right' must not be null."); + + this.Left = left; + this.Left.Parent = this; + this.OperatorToken = operatorToken; + this.Right = right; + this.Right.Parent = this; + } + + public BaseExpressionSyntax Left { get; private set; } + + public Token OperatorToken { get; private set; } + + public BaseExpressionSyntax Right { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Left; + yield return this.Right; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.Left.Range.Start; + } + + TextPosition calculateEnd() + { + return this.Right.Range.End; + } + } + } + } + + internal sealed class ObjectAccessExpressionSyntax : BaseExpressionSyntax + { + public ObjectAccessExpressionSyntax(BaseExpressionSyntax baseExpression, Token dotToken, Token identifierToken) + { + Debug.Assert(!baseExpression.IsDefault(), "'baseExpression' must not be null."); + Debug.Assert(!dotToken.IsDefault(), "'dotToken' must not be null."); + Debug.Assert(dotToken.Kind == TokenKind.Dot, "'dotToken' must have a TokenKind of 'Dot'."); + Debug.Assert(!identifierToken.IsDefault(), "'identifierToken' must not be null."); + Debug.Assert(identifierToken.Kind == TokenKind.Identifier, "'identifierToken' must have a TokenKind of 'Identifier'."); + + this.BaseExpression = baseExpression; + this.BaseExpression.Parent = this; + this.DotToken = dotToken; + this.IdentifierToken = identifierToken; + } + + public BaseExpressionSyntax BaseExpression { get; private set; } + + public Token DotToken { get; private set; } + + public Token IdentifierToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.BaseExpression; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.BaseExpression.Range.Start; + } + + TextPosition calculateEnd() + { + return this.IdentifierToken.Range.End; + } + } + } + } + + internal sealed class ArrayAccessExpressionSyntax : BaseExpressionSyntax + { + public ArrayAccessExpressionSyntax(BaseExpressionSyntax baseExpression, Token leftBracketToken, BaseExpressionSyntax indexExpression, Token rightBracketToken) + { + Debug.Assert(!baseExpression.IsDefault(), "'baseExpression' must not be null."); + Debug.Assert(!leftBracketToken.IsDefault(), "'leftBracketToken' must not be null."); + Debug.Assert(leftBracketToken.Kind == TokenKind.LeftBracket, "'leftBracketToken' must have a TokenKind of 'LeftBracket'."); + Debug.Assert(!indexExpression.IsDefault(), "'indexExpression' must not be null."); + Debug.Assert(!rightBracketToken.IsDefault(), "'rightBracketToken' must not be null."); + Debug.Assert(rightBracketToken.Kind == TokenKind.RightBracket, "'rightBracketToken' must have a TokenKind of 'RightBracket'."); + + this.BaseExpression = baseExpression; + this.BaseExpression.Parent = this; + this.LeftBracketToken = leftBracketToken; + this.IndexExpression = indexExpression; + this.IndexExpression.Parent = this; + this.RightBracketToken = rightBracketToken; + } + + public BaseExpressionSyntax BaseExpression { get; private set; } + + public Token LeftBracketToken { get; private set; } + + public BaseExpressionSyntax IndexExpression { get; private set; } + + public Token RightBracketToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.BaseExpression; + yield return this.IndexExpression; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.BaseExpression.Range.Start; + } + + TextPosition calculateEnd() + { + return this.RightBracketToken.Range.End; + } + } + } + } + + internal sealed class ArgumentSyntax : BaseExpressionSyntax + { + public ArgumentSyntax(BaseExpressionSyntax expression, Token commaTokenOpt) + { + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + if (!commaTokenOpt.IsDefault()) + { + Debug.Assert(commaTokenOpt.Kind == TokenKind.Comma, "'commaTokenOpt' must have a TokenKind of 'Comma'."); + } + + this.Expression = expression; + this.Expression.Parent = this; + this.CommaTokenOpt = commaTokenOpt; + } + + public BaseExpressionSyntax Expression { get; private set; } + + public Token CommaTokenOpt { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.Expression.Range.Start; + } + + TextPosition calculateEnd() + { + if (!this.CommaTokenOpt.IsDefault()) + { + return this.CommaTokenOpt.Range.End; + } + + return this.Expression.Range.End; + } + } + } + } + + internal sealed class InvocationExpressionSyntax : BaseExpressionSyntax + { + public InvocationExpressionSyntax(BaseExpressionSyntax baseExpression, Token leftParenToken, IReadOnlyList arguments, Token rightParenToken) + { + Debug.Assert(!baseExpression.IsDefault(), "'baseExpression' must not be null."); + Debug.Assert(!leftParenToken.IsDefault(), "'leftParenToken' must not be null."); + Debug.Assert(leftParenToken.Kind == TokenKind.LeftParen, "'leftParenToken' must have a TokenKind of 'LeftParen'."); + Debug.Assert(!arguments.IsDefault(), "'arguments' must not be null."); + Debug.Assert(!rightParenToken.IsDefault(), "'rightParenToken' must not be null."); + Debug.Assert(rightParenToken.Kind == TokenKind.RightParen, "'rightParenToken' must have a TokenKind of 'RightParen'."); + + this.BaseExpression = baseExpression; + this.BaseExpression.Parent = this; + this.LeftParenToken = leftParenToken; + this.Arguments = arguments; + foreach (var child in this.Arguments) + { + child.Parent = this; + } + + this.RightParenToken = rightParenToken; + } + + public BaseExpressionSyntax BaseExpression { get; private set; } + + public Token LeftParenToken { get; private set; } + + public IReadOnlyList Arguments { get; private set; } + + public Token RightParenToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.BaseExpression; + foreach (var child in this.Arguments) + { + yield return child; + } + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.BaseExpression.Range.Start; + } + + TextPosition calculateEnd() + { + return this.RightParenToken.Range.End; + } + } + } + } + + internal sealed class ParenthesisExpressionSyntax : BaseExpressionSyntax + { + public ParenthesisExpressionSyntax(Token leftParenToken, BaseExpressionSyntax expression, Token rightParenToken) + { + Debug.Assert(!leftParenToken.IsDefault(), "'leftParenToken' must not be null."); + Debug.Assert(leftParenToken.Kind == TokenKind.LeftParen, "'leftParenToken' must have a TokenKind of 'LeftParen'."); + Debug.Assert(!expression.IsDefault(), "'expression' must not be null."); + Debug.Assert(!rightParenToken.IsDefault(), "'rightParenToken' must not be null."); + Debug.Assert(rightParenToken.Kind == TokenKind.RightParen, "'rightParenToken' must have a TokenKind of 'RightParen'."); + + this.LeftParenToken = leftParenToken; + this.Expression = expression; + this.Expression.Parent = this; + this.RightParenToken = rightParenToken; + } + + public Token LeftParenToken { get; private set; } + + public BaseExpressionSyntax Expression { get; private set; } + + public Token RightParenToken { get; private set; } + + public override IEnumerable Children + { + get + { + yield return this.Expression; + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.LeftParenToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.RightParenToken.Range.End; + } + } + } + } + + internal sealed class IdentifierExpressionSyntax : BaseExpressionSyntax + { + public IdentifierExpressionSyntax(Token identifierToken) + { + Debug.Assert(!identifierToken.IsDefault(), "'identifierToken' must not be null."); + Debug.Assert(identifierToken.Kind == TokenKind.Identifier, "'identifierToken' must have a TokenKind of 'Identifier'."); + + this.IdentifierToken = identifierToken; + } + + public Token IdentifierToken { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.IdentifierToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.IdentifierToken.Range.End; + } + } + } + } + + internal sealed class StringLiteralExpressionSyntax : BaseExpressionSyntax + { + public StringLiteralExpressionSyntax(Token stringToken) + { + Debug.Assert(!stringToken.IsDefault(), "'stringToken' must not be null."); + Debug.Assert(stringToken.Kind == TokenKind.StringLiteral, "'stringToken' must have a TokenKind of 'StringLiteral'."); + + this.StringToken = stringToken; + } + + public Token StringToken { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.StringToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.StringToken.Range.End; + } + } + } + } + + internal sealed class NumberLiteralExpressionSyntax : BaseExpressionSyntax + { + public NumberLiteralExpressionSyntax(Token numberToken) + { + Debug.Assert(!numberToken.IsDefault(), "'numberToken' must not be null."); + Debug.Assert(numberToken.Kind == TokenKind.NumberLiteral, "'numberToken' must have a TokenKind of 'NumberLiteral'."); + + this.NumberToken = numberToken; + } + + public Token NumberToken { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.NumberToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.NumberToken.Range.End; + } + } + } + } + + internal sealed class UnrecognizedExpressionSyntax : BaseExpressionSyntax + { + public UnrecognizedExpressionSyntax(Token unrecognizedToken) + { + Debug.Assert(!unrecognizedToken.IsDefault(), "'unrecognizedToken' must not be null."); + + this.UnrecognizedToken = unrecognizedToken; + } + + public Token UnrecognizedToken { get; private set; } + + public override IEnumerable Children + { + get + { + return Enumerable.Empty(); + } + } + + public override TextRange Range + { + get + { + return (calculateStart(), calculateEnd()); + + TextPosition calculateStart() + { + return this.UnrecognizedToken.Range.Start; + } + + TextPosition calculateEnd() + { + return this.UnrecognizedToken.Range.End; + } + } + } + } +} diff --git a/Source/SmallBasic.Compiler/Parsing/Visitors/SubModuleNamesCollector.cs b/Source/SmallBasic.Compiler/Parsing/Visitors/SubModuleNamesCollector.cs index 2f580d71..96ebbdf3 100644 --- a/Source/SmallBasic.Compiler/Parsing/Visitors/SubModuleNamesCollector.cs +++ b/Source/SmallBasic.Compiler/Parsing/Visitors/SubModuleNamesCollector.cs @@ -22,5 +22,10 @@ private protected override void VisitSubModuleStatement(SubModuleStatementSyntax { this.names.Add(node.NameToken.Text); } + + private protected override void VisitFunctionDeclaration(FunctionDeclarationSyntax node) + { + this.names.Add(node.NameToken.Text); + } } } diff --git a/Source/SmallBasic.Compiler/Runtime/Frame.cs b/Source/SmallBasic.Compiler/Runtime/Frame.cs index 90df540b..ff3e952e 100644 --- a/Source/SmallBasic.Compiler/Runtime/Frame.cs +++ b/Source/SmallBasic.Compiler/Runtime/Frame.cs @@ -10,13 +10,16 @@ public sealed class Frame { private int index = 0; - internal Frame(RuntimeModule module) + internal Frame(RuntimeModule module, bool expectsReturn = false) { this.Module = module; + this.ExpectsReturn = expectsReturn; } public RuntimeModule Module { get; private set; } + public bool ExpectsReturn { get; private set; } + public int InstructionIndex { get diff --git a/Source/SmallBasic.Compiler/Runtime/Instructions/OtherInstructions.cs b/Source/SmallBasic.Compiler/Runtime/Instructions/OtherInstructions.cs index 504d46d8..cd87a442 100644 --- a/Source/SmallBasic.Compiler/Runtime/Instructions/OtherInstructions.cs +++ b/Source/SmallBasic.Compiler/Runtime/Instructions/OtherInstructions.cs @@ -11,20 +11,61 @@ namespace SmallBasic.Compiler.Runtime internal sealed class InvokeSubModuleInstruction : BaseNonJumpInstruction { private readonly string subModuleName; + private readonly bool expectsReturn; - public InvokeSubModuleInstruction(string subModuleName, TextRange range) + public InvokeSubModuleInstruction(string subModuleName, bool expectsReturn, TextRange range) : base(range) { this.subModuleName = subModuleName; + this.expectsReturn = expectsReturn; } protected override void Execute(SmallBasicEngine engine) { - Frame frame = new Frame(engine.Modules[this.subModuleName]); + var module = engine.Modules[this.subModuleName]; + int paramCount = module.Parameters.Count; + var args = new BaseValue[paramCount]; + for (int i = paramCount - 1; i >= 0; i--) + { + args[i] = engine.EvaluationStack.Pop(); + } + + for (int i = 0; i < paramCount; i++) + { + engine.Memory[module.Parameters[i]] = args[i]; + } + + Frame frame = new Frame(module, expectsReturn: this.expectsReturn); engine.ExecutionStack.AddLast(frame); } } + internal sealed class ReturnInstruction : BaseNonJumpInstruction + { + private readonly bool hasExpression; + + public ReturnInstruction(bool hasExpression, TextRange range) + : base(range) + { + this.hasExpression = hasExpression; + } + + protected override void Execute(SmallBasicEngine engine) + { + BaseValue returnValue = this.hasExpression ? engine.EvaluationStack.Pop() : StringValue.Empty; + if (engine.ExecutionStack.Count > 0) + { + var frame = engine.ExecutionStack.Last.Value; + bool expectsReturn = frame.ExpectsReturn; + engine.ExecutionStack.RemoveLast(); + if (expectsReturn) + { + engine.EvaluationStack.Push(returnValue); + } + } + } + } + internal sealed class MethodInvocationInstruction : BaseAsyncNonJumpInstruction { private readonly string library; diff --git a/Source/SmallBasic.Compiler/Runtime/Libraries/BuiltInLibraries.cs b/Source/SmallBasic.Compiler/Runtime/Libraries/BuiltInLibraries.cs new file mode 100644 index 00000000..088100cc --- /dev/null +++ b/Source/SmallBasic.Compiler/Runtime/Libraries/BuiltInLibraries.cs @@ -0,0 +1,268 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +namespace SmallBasic.Compiler.Runtime +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Linq; + using System.Threading.Tasks; + + public class BuiltInLibraries : IEngineLibraries + { + public BuiltInLibraries() + { + this.Math = new BuiltInMathLibrary(); + this.Text = new BuiltInTextLibrary(); + this.Array = new BuiltInArrayLibrary(); + this.TextWindow = new BuiltInTextWindowLibrary(); + } + + public IArrayLibrary Array { get; } + + public IClockLibrary Clock => null; + + public IControlsLibrary Controls => null; + + public IDesktopLibrary Desktop => null; + + public IDictionaryLibrary Dictionary => null; + + public IFileLibrary File => null; + + public IFlickrLibrary Flickr => null; + + public IGraphicsWindowLibrary GraphicsWindow => null; + + public IImageListLibrary ImageList => null; + + public IMathLibrary Math { get; } + + public IMouseLibrary Mouse => null; + + public INetworkLibrary Network => null; + + public IProgramLibrary Program => null; + + public IShapesLibrary Shapes => null; + + public ISoundLibrary Sound => null; + + public IStackLibrary Stack => null; + + public ITextLibrary Text { get; } + + public ITextWindowLibrary TextWindow { get; } + + public ITimerLibrary Timer => null; + + public ITurtleLibrary Turtle => null; + + private class BuiltInMathLibrary : IMathLibrary + { + public decimal Get_Pi() => (decimal)System.Math.PI; + + public decimal Abs(decimal number) => System.Math.Abs(number); + + public decimal Ceiling(decimal number) => System.Math.Ceiling(number); + + public decimal Floor(decimal number) => System.Math.Floor(number); + + public decimal NaturalLog(decimal number) => (decimal)System.Math.Log((double)number); + + public decimal Log(decimal number) => (decimal)System.Math.Log10((double)number); + + public decimal Cos(decimal angle) => (decimal)System.Math.Cos((double)angle); + + public decimal Sin(decimal angle) => (decimal)System.Math.Sin((double)angle); + + public decimal Tan(decimal angle) => (decimal)System.Math.Tan((double)angle); + + public decimal ArcCos(decimal cosValue) => (decimal)System.Math.Acos((double)cosValue); + + public decimal ArcSin(decimal sinValue) => (decimal)System.Math.Asin((double)sinValue); + + public decimal ArcTan(decimal tanValue) => (decimal)System.Math.Atan((double)tanValue); + + public decimal GetDegrees(decimal angle) => angle * (180m / (decimal)System.Math.PI); + + public decimal GetRadians(decimal angle) => angle * ((decimal)System.Math.PI / 180m); + + public decimal SquareRoot(decimal number) => (decimal)System.Math.Sqrt((double)number); + + public decimal Power(decimal baseNumber, decimal exponent) => (decimal)System.Math.Pow((double)baseNumber, (double)exponent); + + public decimal Round(decimal number) => System.Math.Round(number); + + public decimal Max(decimal number1, decimal number2) => System.Math.Max(number1, number2); + + public decimal Min(decimal number1, decimal number2) => System.Math.Min(number1, number2); + + public decimal Remainder(decimal dividend, decimal divisor) => divisor == 0 ? 0 : dividend % divisor; + + public decimal GetRandomNumber(decimal maxNumber) + { + int max = (int)maxNumber; + return max <= 0 ? 0 : new Random().Next(1, max + 1); + } + } + + private class BuiltInTextLibrary : ITextLibrary + { + public string Append(string text1, string text2) => (text1 ?? string.Empty) + (text2 ?? string.Empty); + + public decimal GetLength(string text) => (text ?? string.Empty).Length; + + public string GetSubText(string text, decimal start, decimal length) + { + if (string.IsNullOrEmpty(text) || start < 1 || length <= 0) + { + return string.Empty; + } + + int startIndex = (int)start - 1; + int len = (int)length; + + if (startIndex >= text.Length) + { + return string.Empty; + } + + if (startIndex + len > text.Length) + { + len = text.Length - startIndex; + } + + return text.Substring(startIndex, len); + } + + public string GetSubTextToEnd(string text, decimal start) + { + if (string.IsNullOrEmpty(text) || start < 1) + { + return string.Empty; + } + + int startIndex = (int)start - 1; + + if (startIndex >= text.Length) + { + return string.Empty; + } + + return text.Substring(startIndex); + } + + public decimal GetIndexOf(string text, string subText) + { + if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(subText)) + { + return 0; + } + + int idx = text.IndexOf(subText, StringComparison.Ordinal); + return idx < 0 ? 0 : idx + 1; + } + +#pragma warning disable CA1308 // Normalize strings to uppercase + public string ConvertToLowerCase(string text) => (text ?? string.Empty).ToLower(CultureInfo.InvariantCulture); +#pragma warning restore CA1308 + + public string ConvertToUpperCase(string text) => (text ?? string.Empty).ToUpper(CultureInfo.InvariantCulture); + + public string GetCharacter(decimal characterCode) => ((char)(int)characterCode).ToString(CultureInfo.InvariantCulture); + + public decimal GetCharacterCode(string character) => string.IsNullOrEmpty(character) ? 0 : (decimal)character[0]; + + public bool IsSubText(string text, string subText) => (text ?? string.Empty).Contains(subText ?? string.Empty); + + public bool StartsWith(string text, string subText) => (text ?? string.Empty).StartsWith(subText ?? string.Empty, StringComparison.Ordinal); + + public bool EndsWith(string text, string subText) => (text ?? string.Empty).EndsWith(subText ?? string.Empty, StringComparison.Ordinal); + } + + private class BuiltInArrayLibrary : IArrayLibrary + { + public bool ContainsIndex(ArrayValue array, string index) => array.ContainsKey(index); + + public bool ContainsValue(ArrayValue array, string value) => array.Values.Any(v => v.ToString() == value); + + public ArrayValue GetAllIndices(ArrayValue array) + { + int i = 1; + return new ArrayValue(array.Keys.Select(k => StringValue.Create(k)).ToDictionary(value => (i++).ToString(CultureInfo.InvariantCulture))); + } + + public decimal GetItemCount(ArrayValue array) => array.Count; + + public bool IsArray(BaseValue array) => array is ArrayValue; + + public BaseValue GetValue(string arrayName, string index) => StringValue.Empty; + + public void SetValue(string arrayName, string index, BaseValue value) + { + } + + public void RemoveValue(string arrayName, string index) + { + } + } + + private class BuiltInTextWindowLibrary : ITextWindowLibrary + { + public string Get_BackgroundColor() => Console.BackgroundColor.ToString(); + + public void Set_BackgroundColor(string value) + { + } + + public string Get_ForegroundColor() => Console.ForegroundColor.ToString(); + + public void Set_ForegroundColor(string value) + { + } + + public string Get_Title() => Console.Title; + + public void Set_Title(string value) + { + try + { + Console.Title = value ?? string.Empty; + } + catch + { + } + } + + public void Clear() + { + try + { + Console.Clear(); + } + catch + { + } + } + + public string Read() => Console.ReadLine() ?? string.Empty; + + public decimal ReadNumber() => decimal.TryParse(Console.ReadLine(), out decimal result) ? result : 0; + + public Task Write(string data) + { + Console.Write(data ?? string.Empty); + return Task.CompletedTask; + } + + public Task WriteLine(string data) + { + Console.WriteLine(data ?? string.Empty); + return Task.CompletedTask; + } + } + } +} diff --git a/Source/SmallBasic.Compiler/Runtime/Libraries/Libraries.Generated.cs b/Source/SmallBasic.Compiler/Runtime/Libraries/Libraries.Generated.cs index a3c4a4d3..55803054 100644 --- a/Source/SmallBasic.Compiler/Runtime/Libraries/Libraries.Generated.cs +++ b/Source/SmallBasic.Compiler/Runtime/Libraries/Libraries.Generated.cs @@ -1,5183 +1,5183 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Compiler.Runtime -{ - using System; - using System.Collections.Generic; - using System.Threading.Tasks; - using SmallBasic.Utilities.Resources; - - internal delegate Task DExecuteLibraryMember(SmallBasicEngine engine); - - public sealed class Library - { - internal Library( - string name, - string description, - string explorerIcon, - bool usesGraphicsWindow, - bool usesTextWindow, - IReadOnlyDictionary methods, - IReadOnlyDictionary properties, - IReadOnlyDictionary events) - { - this.Name = name; - this.Description = description; - this.ExplorerIcon = explorerIcon; - this.UsesGraphicsWindow = usesGraphicsWindow; - this.UsesTextWindow = usesTextWindow; - this.Methods = methods; - this.Properties = properties; - this.Events = events; - } - - public string Name { get; private set; } - - public string Description { get; private set; } - - public string ExplorerIcon { get; private set; } - - public bool UsesGraphicsWindow { get; private set; } - - public bool UsesTextWindow { get; private set; } - - public IReadOnlyDictionary Methods { get; private set; } - - public IReadOnlyDictionary Properties { get; private set; } - - public IReadOnlyDictionary Events { get; private set; } - } - - public sealed class Parameter - { - internal Parameter( - string name, - string description) - { - this.Name = name; - this.Description = description; - } - - public string Name { get; private set; } - - public string Description { get; private set; } - } - - public sealed class Method - { - internal Method( - string name, - string description, - bool returnsValue, - string returnValueDescription, - IReadOnlyDictionary parameters, - bool isDeprecated, - bool needsDesktop, - DExecuteLibraryMember execute) - { - this.Name = name; - this.Description = description; - this.ReturnsValue = returnsValue; - this.ReturnValueDescription = returnValueDescription; - this.Parameters = parameters; - this.IsDeprecated = isDeprecated; - this.NeedsDesktop = needsDesktop; - this.Execute = execute; - } - - public string Name { get; private set; } - - public string Description { get; private set; } - - public bool ReturnsValue { get; private set; } - - public string ReturnValueDescription { get; private set; } - - public IReadOnlyDictionary Parameters { get; private set; } - - internal bool IsDeprecated { get; private set; } - - internal bool NeedsDesktop { get; private set; } - - internal DExecuteLibraryMember Execute { get; private set; } - } - - public sealed class Property - { - internal Property( - string name, - string description, - bool isDeprecated, - bool needsDesktop, - DExecuteLibraryMember getter, - DExecuteLibraryMember setter) - { - this.Name = name; - this.Description = description; - this.IsDeprecated = isDeprecated; - this.NeedsDesktop = needsDesktop; - this.Getter = getter; - this.Setter = setter; - } - - public string Name { get; private set; } - - public string Description { get; private set; } - - internal bool IsDeprecated { get; private set; } - - internal bool NeedsDesktop { get; private set; } - - internal DExecuteLibraryMember Getter { get; private set; } - - internal DExecuteLibraryMember Setter { get; private set; } - } - - public sealed class Event - { - internal Event( - string name, - string description) - { - this.Name = name; - this.Description = description; - } - - public string Name { get; private set; } - - public string Description { get; private set; } - } - - public static class Libraries - { - public static readonly IReadOnlyDictionary Types; - - static Libraries() - { - var types = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for library 'Array' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Array.ContainsIndex: - { - Task execute(SmallBasicEngine engine) - { - string index = engine.EvaluationStack.Pop().ToString(); - ArrayValue array = engine.EvaluationStack.Pop().ToArray(); - bool returnValue = engine.Libraries.Array.ContainsIndex(array: array, index: index); - engine.EvaluationStack.Push(new BooleanValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("ContainsIndex", new Method( - name: "ContainsIndex", - description: LibrariesResources.Array_ContainsIndex, - returnsValue: true, - returnValueDescription: LibrariesResources.Array_ContainsIndex_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "array", new Parameter("array", LibrariesResources.Array_ContainsIndex_array) }, - { "index", new Parameter("index", LibrariesResources.Array_ContainsIndex_index) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Array.ContainsValue: - { - Task execute(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - ArrayValue array = engine.EvaluationStack.Pop().ToArray(); - bool returnValue = engine.Libraries.Array.ContainsValue(array: array, value: value); - engine.EvaluationStack.Push(new BooleanValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("ContainsValue", new Method( - name: "ContainsValue", - description: LibrariesResources.Array_ContainsValue, - returnsValue: true, - returnValueDescription: LibrariesResources.Array_ContainsValue_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "array", new Parameter("array", LibrariesResources.Array_ContainsValue_array) }, - { "value", new Parameter("value", LibrariesResources.Array_ContainsValue_value) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Array.GetAllIndices: - { - Task execute(SmallBasicEngine engine) - { - ArrayValue array = engine.EvaluationStack.Pop().ToArray(); - ArrayValue returnValue = engine.Libraries.Array.GetAllIndices(array: array); - engine.EvaluationStack.Push(returnValue); - return Task.CompletedTask; - } - - methods.Add("GetAllIndices", new Method( - name: "GetAllIndices", - description: LibrariesResources.Array_GetAllIndices, - returnsValue: true, - returnValueDescription: LibrariesResources.Array_GetAllIndices_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "array", new Parameter("array", LibrariesResources.Array_GetAllIndices_array) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Array.GetItemCount: - { - Task execute(SmallBasicEngine engine) - { - ArrayValue array = engine.EvaluationStack.Pop().ToArray(); - decimal returnValue = engine.Libraries.Array.GetItemCount(array: array); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetItemCount", new Method( - name: "GetItemCount", - description: LibrariesResources.Array_GetItemCount, - returnsValue: true, - returnValueDescription: LibrariesResources.Array_GetItemCount_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "array", new Parameter("array", LibrariesResources.Array_GetItemCount_array) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Array.GetValue: - { - Task execute(SmallBasicEngine engine) - { - string index = engine.EvaluationStack.Pop().ToString(); - string arrayName = engine.EvaluationStack.Pop().ToString(); - BaseValue returnValue = engine.Libraries.Array.GetValue(arrayName: arrayName, index: index); - engine.EvaluationStack.Push(returnValue); - return Task.CompletedTask; - } - - methods.Add("GetValue", new Method( - name: "GetValue", - description: LibrariesResources.Array_GetValue, - returnsValue: true, - returnValueDescription: LibrariesResources.Array_GetValue_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "arrayName", new Parameter("arrayName", LibrariesResources.Array_GetValue_arrayName) }, - { "index", new Parameter("index", LibrariesResources.Array_GetValue_index) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Array.IsArray: - { - Task execute(SmallBasicEngine engine) - { - BaseValue array = engine.EvaluationStack.Pop(); - bool returnValue = engine.Libraries.Array.IsArray(array: array); - engine.EvaluationStack.Push(new BooleanValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("IsArray", new Method( - name: "IsArray", - description: LibrariesResources.Array_IsArray, - returnsValue: true, - returnValueDescription: LibrariesResources.Array_IsArray_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "array", new Parameter("array", LibrariesResources.Array_IsArray_array) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Array.RemoveValue: - { - Task execute(SmallBasicEngine engine) - { - string index = engine.EvaluationStack.Pop().ToString(); - string arrayName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Array.RemoveValue(arrayName: arrayName, index: index); - return Task.CompletedTask; - } - - methods.Add("RemoveValue", new Method( - name: "RemoveValue", - description: LibrariesResources.Array_RemoveValue, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "arrayName", new Parameter("arrayName", LibrariesResources.Array_RemoveValue_arrayName) }, - { "index", new Parameter("index", LibrariesResources.Array_RemoveValue_index) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Array.SetValue: - { - Task execute(SmallBasicEngine engine) - { - BaseValue value = engine.EvaluationStack.Pop(); - string index = engine.EvaluationStack.Pop().ToString(); - string arrayName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Array.SetValue(arrayName: arrayName, index: index, value: value); - return Task.CompletedTask; - } - - methods.Add("SetValue", new Method( - name: "SetValue", - description: LibrariesResources.Array_SetValue, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "arrayName", new Parameter("arrayName", LibrariesResources.Array_SetValue_arrayName) }, - { "index", new Parameter("index", LibrariesResources.Array_SetValue_index) }, - { "value", new Parameter("value", LibrariesResources.Array_SetValue_value) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Array", new Library("Array", LibrariesResources.Array, "th-list", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Clock' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property Clock.Date: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.Clock.Get_Date(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - properties.Add("Date", new Property("Date", LibrariesResources.Clock_Date, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.Day: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Clock.Get_Day(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("Day", new Property("Day", LibrariesResources.Clock_Day, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.ElapsedMilliseconds: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Clock.Get_ElapsedMilliseconds(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("ElapsedMilliseconds", new Property("ElapsedMilliseconds", LibrariesResources.Clock_ElapsedMilliseconds, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.Hour: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Clock.Get_Hour(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("Hour", new Property("Hour", LibrariesResources.Clock_Hour, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.Millisecond: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Clock.Get_Millisecond(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("Millisecond", new Property("Millisecond", LibrariesResources.Clock_Millisecond, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.Minute: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Clock.Get_Minute(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("Minute", new Property("Minute", LibrariesResources.Clock_Minute, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.Month: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Clock.Get_Month(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("Month", new Property("Month", LibrariesResources.Clock_Month, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.Second: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Clock.Get_Second(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("Second", new Property("Second", LibrariesResources.Clock_Second, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.Time: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.Clock.Get_Time(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - properties.Add("Time", new Property("Time", LibrariesResources.Clock_Time, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.WeekDay: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.Clock.Get_WeekDay(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - properties.Add("WeekDay", new Property("WeekDay", LibrariesResources.Clock_WeekDay, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Clock.Year: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Clock.Get_Year(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("Year", new Property("Year", LibrariesResources.Clock_Year, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Clock", new Library("Clock", LibrariesResources.Clock, "clock", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Controls' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Controls.AddButton: - { - Task execute(SmallBasicEngine engine) - { - decimal top = engine.EvaluationStack.Pop().ToNumber(); - decimal left = engine.EvaluationStack.Pop().ToNumber(); - string caption = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Controls.AddButton(caption: caption, left: left, top: top); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("AddButton", new Method( - name: "AddButton", - description: LibrariesResources.Controls_AddButton, - returnsValue: true, - returnValueDescription: LibrariesResources.Controls_AddButton_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "caption", new Parameter("caption", LibrariesResources.Controls_AddButton_caption) }, - { "left", new Parameter("left", LibrariesResources.Controls_AddButton_left) }, - { "top", new Parameter("top", LibrariesResources.Controls_AddButton_top) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.AddMultiLineTextBox: - { - Task execute(SmallBasicEngine engine) - { - decimal top = engine.EvaluationStack.Pop().ToNumber(); - decimal left = engine.EvaluationStack.Pop().ToNumber(); - string returnValue = engine.Libraries.Controls.AddMultiLineTextBox(left: left, top: top); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("AddMultiLineTextBox", new Method( - name: "AddMultiLineTextBox", - description: LibrariesResources.Controls_AddMultiLineTextBox, - returnsValue: true, - returnValueDescription: LibrariesResources.Controls_AddMultiLineTextBox_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "left", new Parameter("left", LibrariesResources.Controls_AddMultiLineTextBox_left) }, - { "top", new Parameter("top", LibrariesResources.Controls_AddMultiLineTextBox_top) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.AddTextBox: - { - Task execute(SmallBasicEngine engine) - { - decimal top = engine.EvaluationStack.Pop().ToNumber(); - decimal left = engine.EvaluationStack.Pop().ToNumber(); - string returnValue = engine.Libraries.Controls.AddTextBox(left: left, top: top); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("AddTextBox", new Method( - name: "AddTextBox", - description: LibrariesResources.Controls_AddTextBox, - returnsValue: true, - returnValueDescription: LibrariesResources.Controls_AddTextBox_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "left", new Parameter("left", LibrariesResources.Controls_AddTextBox_left) }, - { "top", new Parameter("top", LibrariesResources.Controls_AddTextBox_top) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.GetButtonCaption: - { - Task execute(SmallBasicEngine engine) - { - string buttonName = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Controls.GetButtonCaption(buttonName: buttonName); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetButtonCaption", new Method( - name: "GetButtonCaption", - description: LibrariesResources.Controls_GetButtonCaption, - returnsValue: true, - returnValueDescription: LibrariesResources.Controls_GetButtonCaption_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "buttonName", new Parameter("buttonName", LibrariesResources.Controls_GetButtonCaption_buttonName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.GetTextBoxText: - { - Task execute(SmallBasicEngine engine) - { - string textBoxName = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Controls.GetTextBoxText(textBoxName: textBoxName); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetTextBoxText", new Method( - name: "GetTextBoxText", - description: LibrariesResources.Controls_GetTextBoxText, - returnsValue: true, - returnValueDescription: LibrariesResources.Controls_GetTextBoxText_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "textBoxName", new Parameter("textBoxName", LibrariesResources.Controls_GetTextBoxText_textBoxName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.HideControl: - { - Task execute(SmallBasicEngine engine) - { - string controlName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Controls.HideControl(controlName: controlName); - return Task.CompletedTask; - } - - methods.Add("HideControl", new Method( - name: "HideControl", - description: LibrariesResources.Controls_HideControl, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "controlName", new Parameter("controlName", LibrariesResources.Controls_HideControl_controlName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.Move: - { - Task execute(SmallBasicEngine engine) - { - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - string control = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Controls.Move(control: control, x: x, y: y); - return Task.CompletedTask; - } - - methods.Add("Move", new Method( - name: "Move", - description: LibrariesResources.Controls_Move, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "control", new Parameter("control", LibrariesResources.Controls_Move_control) }, - { "x", new Parameter("x", LibrariesResources.Controls_Move_x) }, - { "y", new Parameter("y", LibrariesResources.Controls_Move_y) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.Remove: - { - Task execute(SmallBasicEngine engine) - { - string controlName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Controls.Remove(controlName: controlName); - return Task.CompletedTask; - } - - methods.Add("Remove", new Method( - name: "Remove", - description: LibrariesResources.Controls_Remove, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "controlName", new Parameter("controlName", LibrariesResources.Controls_Remove_controlName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.SetButtonCaption: - { - Task execute(SmallBasicEngine engine) - { - string caption = engine.EvaluationStack.Pop().ToString(); - string buttonName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Controls.SetButtonCaption(buttonName: buttonName, caption: caption); - return Task.CompletedTask; - } - - methods.Add("SetButtonCaption", new Method( - name: "SetButtonCaption", - description: LibrariesResources.Controls_SetButtonCaption, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "buttonName", new Parameter("buttonName", LibrariesResources.Controls_SetButtonCaption_buttonName) }, - { "caption", new Parameter("caption", LibrariesResources.Controls_SetButtonCaption_caption) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.SetSize: - { - Task execute(SmallBasicEngine engine) - { - decimal height = engine.EvaluationStack.Pop().ToNumber(); - decimal width = engine.EvaluationStack.Pop().ToNumber(); - string control = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Controls.SetSize(control: control, width: width, height: height); - return Task.CompletedTask; - } - - methods.Add("SetSize", new Method( - name: "SetSize", - description: LibrariesResources.Controls_SetSize, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "control", new Parameter("control", LibrariesResources.Controls_SetSize_control) }, - { "width", new Parameter("width", LibrariesResources.Controls_SetSize_width) }, - { "height", new Parameter("height", LibrariesResources.Controls_SetSize_height) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.SetTextBoxText: - { - Task execute(SmallBasicEngine engine) - { - string text = engine.EvaluationStack.Pop().ToString(); - string textBoxName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Controls.SetTextBoxText(textBoxName: textBoxName, text: text); - return Task.CompletedTask; - } - - methods.Add("SetTextBoxText", new Method( - name: "SetTextBoxText", - description: LibrariesResources.Controls_SetTextBoxText, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "textBoxName", new Parameter("textBoxName", LibrariesResources.Controls_SetTextBoxText_textBoxName) }, - { "text", new Parameter("text", LibrariesResources.Controls_SetTextBoxText_text) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Controls.ShowControl: - { - Task execute(SmallBasicEngine engine) - { - string controlName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Controls.ShowControl(controlName: controlName); - return Task.CompletedTask; - } - - methods.Add("ShowControl", new Method( - name: "ShowControl", - description: LibrariesResources.Controls_ShowControl, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "controlName", new Parameter("controlName", LibrariesResources.Controls_ShowControl_controlName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property Controls.LastClickedButton: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.Controls.Get_LastClickedButton(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - properties.Add("LastClickedButton", new Property("LastClickedButton", LibrariesResources.Controls_LastClickedButton, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Controls.LastTypedTextBox: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.Controls.Get_LastTypedTextBox(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - properties.Add("LastTypedTextBox", new Property("LastTypedTextBox", LibrariesResources.Controls_LastTypedTextBox, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "ButtonClicked", new Event("ButtonClicked", LibrariesResources.Controls_ButtonClicked) }, - { "TextTyped", new Event("TextTyped", LibrariesResources.Controls_TextTyped) }, - }; - - types.Add("Controls", new Library("Controls", LibrariesResources.Controls, "sliders-h", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Desktop' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Desktop.SetWallPaper: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Desktop.SetWallPaper' is deprecated."); - } - - methods.Add("SetWallPaper", new Method( - name: "SetWallPaper", - description: LibrariesResources.Desktop_SetWallPaper, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "fileOrUrl", new Parameter("fileOrUrl", LibrariesResources.Desktop_SetWallPaper_fileOrUrl) }, - }, - isDeprecated: true, - needsDesktop: true, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property Desktop.Height: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'Desktop.Height' is deprecated."); - } - - properties.Add("Height", new Property("Height", LibrariesResources.Desktop_Height, isDeprecated: true, needsDesktop: true, getter: getter, setter: null)); - } - - // Initialization code for property Desktop.Width: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'Desktop.Width' is deprecated."); - } - - properties.Add("Width", new Property("Width", LibrariesResources.Desktop_Width, isDeprecated: true, needsDesktop: true, getter: getter, setter: null)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Desktop", new Library("Desktop", LibrariesResources.Desktop, "desktop", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Dictionary' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Dictionary.GetDefinition: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinition' is deprecated."); - } - - methods.Add("GetDefinition", new Method( - name: "GetDefinition", - description: LibrariesResources.Dictionary_GetDefinition, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinition_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinition_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionEnglishToEnglish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToEnglish' is deprecated."); - } - - methods.Add("GetDefinitionEnglishToEnglish", new Method( - name: "GetDefinitionEnglishToEnglish", - description: LibrariesResources.Dictionary_GetDefinitionEnglishToEnglish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToEnglish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToEnglish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionEnglishToFrench: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToFrench' is deprecated."); - } - - methods.Add("GetDefinitionEnglishToFrench", new Method( - name: "GetDefinitionEnglishToFrench", - description: LibrariesResources.Dictionary_GetDefinitionEnglishToFrench, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToFrench_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToFrench_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionEnglishToGerman: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToGerman' is deprecated."); - } - - methods.Add("GetDefinitionEnglishToGerman", new Method( - name: "GetDefinitionEnglishToGerman", - description: LibrariesResources.Dictionary_GetDefinitionEnglishToGerman, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToGerman_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToGerman_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionEnglishToItalian: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToItalian' is deprecated."); - } - - methods.Add("GetDefinitionEnglishToItalian", new Method( - name: "GetDefinitionEnglishToItalian", - description: LibrariesResources.Dictionary_GetDefinitionEnglishToItalian, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToItalian_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToItalian_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionEnglishToJapanese: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToJapanese' is deprecated."); - } - - methods.Add("GetDefinitionEnglishToJapanese", new Method( - name: "GetDefinitionEnglishToJapanese", - description: LibrariesResources.Dictionary_GetDefinitionEnglishToJapanese, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToJapanese_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToJapanese_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionEnglishToKorean: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToKorean' is deprecated."); - } - - methods.Add("GetDefinitionEnglishToKorean", new Method( - name: "GetDefinitionEnglishToKorean", - description: LibrariesResources.Dictionary_GetDefinitionEnglishToKorean, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToKorean_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToKorean_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionEnglishToSimplifiedChinese: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToSimplifiedChinese' is deprecated."); - } - - methods.Add("GetDefinitionEnglishToSimplifiedChinese", new Method( - name: "GetDefinitionEnglishToSimplifiedChinese", - description: LibrariesResources.Dictionary_GetDefinitionEnglishToSimplifiedChinese, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToSimplifiedChinese_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToSimplifiedChinese_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionEnglishToSpanish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToSpanish' is deprecated."); - } - - methods.Add("GetDefinitionEnglishToSpanish", new Method( - name: "GetDefinitionEnglishToSpanish", - description: LibrariesResources.Dictionary_GetDefinitionEnglishToSpanish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToSpanish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToSpanish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionEnglishToTraditionalChinese: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToTraditionalChinese' is deprecated."); - } - - methods.Add("GetDefinitionEnglishToTraditionalChinese", new Method( - name: "GetDefinitionEnglishToTraditionalChinese", - description: LibrariesResources.Dictionary_GetDefinitionEnglishToTraditionalChinese, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToTraditionalChinese_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToTraditionalChinese_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionFrenchToEnglish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionFrenchToEnglish' is deprecated."); - } - - methods.Add("GetDefinitionFrenchToEnglish", new Method( - name: "GetDefinitionFrenchToEnglish", - description: LibrariesResources.Dictionary_GetDefinitionFrenchToEnglish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionFrenchToEnglish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionFrenchToEnglish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionGermanToEnglish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionGermanToEnglish' is deprecated."); - } - - methods.Add("GetDefinitionGermanToEnglish", new Method( - name: "GetDefinitionGermanToEnglish", - description: LibrariesResources.Dictionary_GetDefinitionGermanToEnglish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionGermanToEnglish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionGermanToEnglish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionItalianToEnglish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionItalianToEnglish' is deprecated."); - } - - methods.Add("GetDefinitionItalianToEnglish", new Method( - name: "GetDefinitionItalianToEnglish", - description: LibrariesResources.Dictionary_GetDefinitionItalianToEnglish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionItalianToEnglish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionItalianToEnglish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionJapaneseToEnglish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionJapaneseToEnglish' is deprecated."); - } - - methods.Add("GetDefinitionJapaneseToEnglish", new Method( - name: "GetDefinitionJapaneseToEnglish", - description: LibrariesResources.Dictionary_GetDefinitionJapaneseToEnglish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionJapaneseToEnglish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionJapaneseToEnglish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionKoreanToEnglish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionKoreanToEnglish' is deprecated."); - } - - methods.Add("GetDefinitionKoreanToEnglish", new Method( - name: "GetDefinitionKoreanToEnglish", - description: LibrariesResources.Dictionary_GetDefinitionKoreanToEnglish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionKoreanToEnglish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionKoreanToEnglish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionSimplifiedChineseToEnglish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionSimplifiedChineseToEnglish' is deprecated."); - } - - methods.Add("GetDefinitionSimplifiedChineseToEnglish", new Method( - name: "GetDefinitionSimplifiedChineseToEnglish", - description: LibrariesResources.Dictionary_GetDefinitionSimplifiedChineseToEnglish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionSimplifiedChineseToEnglish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionSimplifiedChineseToEnglish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionSpanishToEnglish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionSpanishToEnglish' is deprecated."); - } - - methods.Add("GetDefinitionSpanishToEnglish", new Method( - name: "GetDefinitionSpanishToEnglish", - description: LibrariesResources.Dictionary_GetDefinitionSpanishToEnglish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionSpanishToEnglish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionSpanishToEnglish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Dictionary.GetDefinitionTraditionalChineseToEnglish: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionTraditionalChineseToEnglish' is deprecated."); - } - - methods.Add("GetDefinitionTraditionalChineseToEnglish", new Method( - name: "GetDefinitionTraditionalChineseToEnglish", - description: LibrariesResources.Dictionary_GetDefinitionTraditionalChineseToEnglish, - returnsValue: true, - returnValueDescription: LibrariesResources.Dictionary_GetDefinitionTraditionalChineseToEnglish_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionTraditionalChineseToEnglish_word) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Dictionary", new Library("Dictionary", LibrariesResources.Dictionary, "font", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'File' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method File.AppendContents: - { - async Task execute(SmallBasicEngine engine) - { - string contents = engine.EvaluationStack.Pop().ToString(); - string filePath = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.File.AppendContents(filePath: filePath, contents: contents).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("AppendContents", new Method( - name: "AppendContents", - description: LibrariesResources.File_AppendContents, - returnsValue: true, - returnValueDescription: LibrariesResources.File_AppendContents_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.File_AppendContents_filePath) }, - { "contents", new Parameter("contents", LibrariesResources.File_AppendContents_contents) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.CopyFile: - { - async Task execute(SmallBasicEngine engine) - { - string destinationFilePath = engine.EvaluationStack.Pop().ToString(); - string sourceFilePath = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.File.CopyFile(sourceFilePath: sourceFilePath, destinationFilePath: destinationFilePath).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("CopyFile", new Method( - name: "CopyFile", - description: LibrariesResources.File_CopyFile, - returnsValue: true, - returnValueDescription: LibrariesResources.File_CopyFile_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "sourceFilePath", new Parameter("sourceFilePath", LibrariesResources.File_CopyFile_sourceFilePath) }, - { "destinationFilePath", new Parameter("destinationFilePath", LibrariesResources.File_CopyFile_destinationFilePath) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.CreateDirectory: - { - async Task execute(SmallBasicEngine engine) - { - string directoryPath = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.File.CreateDirectory(directoryPath: directoryPath).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("CreateDirectory", new Method( - name: "CreateDirectory", - description: LibrariesResources.File_CreateDirectory, - returnsValue: true, - returnValueDescription: LibrariesResources.File_CreateDirectory_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "directoryPath", new Parameter("directoryPath", LibrariesResources.File_CreateDirectory_directoryPath) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.DeleteDirectory: - { - async Task execute(SmallBasicEngine engine) - { - string directoryPath = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.File.DeleteDirectory(directoryPath: directoryPath).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("DeleteDirectory", new Method( - name: "DeleteDirectory", - description: LibrariesResources.File_DeleteDirectory, - returnsValue: true, - returnValueDescription: LibrariesResources.File_DeleteDirectory_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "directoryPath", new Parameter("directoryPath", LibrariesResources.File_DeleteDirectory_directoryPath) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.DeleteFile: - { - async Task execute(SmallBasicEngine engine) - { - string filePath = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.File.DeleteFile(filePath: filePath).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("DeleteFile", new Method( - name: "DeleteFile", - description: LibrariesResources.File_DeleteFile, - returnsValue: true, - returnValueDescription: LibrariesResources.File_DeleteFile_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.File_DeleteFile_filePath) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.GetDirectories: - { - async Task execute(SmallBasicEngine engine) - { - string directoryPath = engine.EvaluationStack.Pop().ToString(); - BaseValue returnValue = await engine.Libraries.File.GetDirectories(directoryPath: directoryPath).ConfigureAwait(false); - engine.EvaluationStack.Push(returnValue); - } - - methods.Add("GetDirectories", new Method( - name: "GetDirectories", - description: LibrariesResources.File_GetDirectories, - returnsValue: true, - returnValueDescription: LibrariesResources.File_GetDirectories_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "directoryPath", new Parameter("directoryPath", LibrariesResources.File_GetDirectories_directoryPath) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.GetFiles: - { - async Task execute(SmallBasicEngine engine) - { - string directoryPath = engine.EvaluationStack.Pop().ToString(); - BaseValue returnValue = await engine.Libraries.File.GetFiles(directoryPath: directoryPath).ConfigureAwait(false); - engine.EvaluationStack.Push(returnValue); - } - - methods.Add("GetFiles", new Method( - name: "GetFiles", - description: LibrariesResources.File_GetFiles, - returnsValue: true, - returnValueDescription: LibrariesResources.File_GetFiles_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "directoryPath", new Parameter("directoryPath", LibrariesResources.File_GetFiles_directoryPath) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.GetSettingsFilePath: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'File.GetSettingsFilePath' is deprecated."); - } - - methods.Add("GetSettingsFilePath", new Method( - name: "GetSettingsFilePath", - description: LibrariesResources.File_GetSettingsFilePath, - returnsValue: true, - returnValueDescription: LibrariesResources.File_GetSettingsFilePath_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.GetTemporaryFilePath: - { - async Task execute(SmallBasicEngine engine) - { - BaseValue returnValue = await engine.Libraries.File.GetTemporaryFilePath().ConfigureAwait(false); - engine.EvaluationStack.Push(returnValue); - } - - methods.Add("GetTemporaryFilePath", new Method( - name: "GetTemporaryFilePath", - description: LibrariesResources.File_GetTemporaryFilePath, - returnsValue: true, - returnValueDescription: LibrariesResources.File_GetTemporaryFilePath_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.InsertLine: - { - async Task execute(SmallBasicEngine engine) - { - string contents = engine.EvaluationStack.Pop().ToString(); - decimal lineNumber = engine.EvaluationStack.Pop().ToNumber(); - string filePath = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.File.InsertLine(filePath: filePath, lineNumber: lineNumber, contents: contents).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("InsertLine", new Method( - name: "InsertLine", - description: LibrariesResources.File_InsertLine, - returnsValue: true, - returnValueDescription: LibrariesResources.File_InsertLine_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.File_InsertLine_filePath) }, - { "lineNumber", new Parameter("lineNumber", LibrariesResources.File_InsertLine_lineNumber) }, - { "contents", new Parameter("contents", LibrariesResources.File_InsertLine_contents) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.ReadContents: - { - async Task execute(SmallBasicEngine engine) - { - string filePath = engine.EvaluationStack.Pop().ToString(); - BaseValue returnValue = await engine.Libraries.File.ReadContents(filePath: filePath).ConfigureAwait(false); - engine.EvaluationStack.Push(returnValue); - } - - methods.Add("ReadContents", new Method( - name: "ReadContents", - description: LibrariesResources.File_ReadContents, - returnsValue: true, - returnValueDescription: LibrariesResources.File_ReadContents_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.File_ReadContents_filePath) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.ReadLine: - { - async Task execute(SmallBasicEngine engine) - { - decimal lineNumber = engine.EvaluationStack.Pop().ToNumber(); - string filePath = engine.EvaluationStack.Pop().ToString(); - BaseValue returnValue = await engine.Libraries.File.ReadLine(filePath: filePath, lineNumber: lineNumber).ConfigureAwait(false); - engine.EvaluationStack.Push(returnValue); - } - - methods.Add("ReadLine", new Method( - name: "ReadLine", - description: LibrariesResources.File_ReadLine, - returnsValue: true, - returnValueDescription: LibrariesResources.File_ReadLine_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.File_ReadLine_filePath) }, - { "lineNumber", new Parameter("lineNumber", LibrariesResources.File_ReadLine_lineNumber) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.WriteContents: - { - async Task execute(SmallBasicEngine engine) - { - string contents = engine.EvaluationStack.Pop().ToString(); - string filePath = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.File.WriteContents(filePath: filePath, contents: contents).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("WriteContents", new Method( - name: "WriteContents", - description: LibrariesResources.File_WriteContents, - returnsValue: true, - returnValueDescription: LibrariesResources.File_WriteContents_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.File_WriteContents_filePath) }, - { "contents", new Parameter("contents", LibrariesResources.File_WriteContents_contents) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method File.WriteLine: - { - async Task execute(SmallBasicEngine engine) - { - string contents = engine.EvaluationStack.Pop().ToString(); - decimal lineNumber = engine.EvaluationStack.Pop().ToNumber(); - string filePath = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.File.WriteLine(filePath: filePath, lineNumber: lineNumber, contents: contents).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("WriteLine", new Method( - name: "WriteLine", - description: LibrariesResources.File_WriteLine, - returnsValue: true, - returnValueDescription: LibrariesResources.File_WriteLine_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.File_WriteLine_filePath) }, - { "lineNumber", new Parameter("lineNumber", LibrariesResources.File_WriteLine_lineNumber) }, - { "contents", new Parameter("contents", LibrariesResources.File_WriteLine_contents) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property File.LastError: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.File.Get_LastError(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.File.Set_LastError(value); - return Task.CompletedTask; - } - - properties.Add("LastError", new Property("LastError", LibrariesResources.File_LastError, isDeprecated: false, needsDesktop: true, getter: getter, setter: setter)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("File", new Library("File", LibrariesResources.File, "file", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Flickr' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Flickr.GetPictureOfMoment: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Flickr.GetPictureOfMoment' is deprecated."); - } - - methods.Add("GetPictureOfMoment", new Method( - name: "GetPictureOfMoment", - description: LibrariesResources.Flickr_GetPictureOfMoment, - returnsValue: true, - returnValueDescription: LibrariesResources.Flickr_GetPictureOfMoment_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Flickr.GetRandomPicture: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Flickr.GetRandomPicture' is deprecated."); - } - - methods.Add("GetRandomPicture", new Method( - name: "GetRandomPicture", - description: LibrariesResources.Flickr_GetRandomPicture, - returnsValue: true, - returnValueDescription: LibrariesResources.Flickr_GetRandomPicture_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "tag", new Parameter("tag", LibrariesResources.Flickr_GetRandomPicture_tag) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Flickr", new Library("Flickr", LibrariesResources.Flickr, "camera", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'GraphicsWindow' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method GraphicsWindow.Clear: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.GraphicsWindow.Clear(); - return Task.CompletedTask; - } - - methods.Add("Clear", new Method( - name: "Clear", - description: LibrariesResources.GraphicsWindow_Clear, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.DrawBoundText: - { - Task execute(SmallBasicEngine engine) - { - string text = engine.EvaluationStack.Pop().ToString(); - decimal width = engine.EvaluationStack.Pop().ToNumber(); - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.DrawBoundText(x: x, y: y, width: width, text: text); - return Task.CompletedTask; - } - - methods.Add("DrawBoundText", new Method( - name: "DrawBoundText", - description: LibrariesResources.GraphicsWindow_DrawBoundText, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawBoundText_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawBoundText_y) }, - { "width", new Parameter("width", LibrariesResources.GraphicsWindow_DrawBoundText_width) }, - { "text", new Parameter("text", LibrariesResources.GraphicsWindow_DrawBoundText_text) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.DrawEllipse: - { - Task execute(SmallBasicEngine engine) - { - decimal height = engine.EvaluationStack.Pop().ToNumber(); - decimal width = engine.EvaluationStack.Pop().ToNumber(); - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.DrawEllipse(x: x, y: y, width: width, height: height); - return Task.CompletedTask; - } - - methods.Add("DrawEllipse", new Method( - name: "DrawEllipse", - description: LibrariesResources.GraphicsWindow_DrawEllipse, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawEllipse_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawEllipse_y) }, - { "width", new Parameter("width", LibrariesResources.GraphicsWindow_DrawEllipse_width) }, - { "height", new Parameter("height", LibrariesResources.GraphicsWindow_DrawEllipse_height) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.DrawImage: - { - Task execute(SmallBasicEngine engine) - { - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - string imageName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.GraphicsWindow.DrawImage(imageName: imageName, x: x, y: y); - return Task.CompletedTask; - } - - methods.Add("DrawImage", new Method( - name: "DrawImage", - description: LibrariesResources.GraphicsWindow_DrawImage, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "imageName", new Parameter("imageName", LibrariesResources.GraphicsWindow_DrawImage_imageName) }, - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawImage_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawImage_y) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.DrawLine: - { - Task execute(SmallBasicEngine engine) - { - decimal y2 = engine.EvaluationStack.Pop().ToNumber(); - decimal x2 = engine.EvaluationStack.Pop().ToNumber(); - decimal y1 = engine.EvaluationStack.Pop().ToNumber(); - decimal x1 = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.DrawLine(x1: x1, y1: y1, x2: x2, y2: y2); - return Task.CompletedTask; - } - - methods.Add("DrawLine", new Method( - name: "DrawLine", - description: LibrariesResources.GraphicsWindow_DrawLine, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x1", new Parameter("x1", LibrariesResources.GraphicsWindow_DrawLine_x1) }, - { "y1", new Parameter("y1", LibrariesResources.GraphicsWindow_DrawLine_y1) }, - { "x2", new Parameter("x2", LibrariesResources.GraphicsWindow_DrawLine_x2) }, - { "y2", new Parameter("y2", LibrariesResources.GraphicsWindow_DrawLine_y2) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.DrawRectangle: - { - Task execute(SmallBasicEngine engine) - { - decimal height = engine.EvaluationStack.Pop().ToNumber(); - decimal width = engine.EvaluationStack.Pop().ToNumber(); - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.DrawRectangle(x: x, y: y, width: width, height: height); - return Task.CompletedTask; - } - - methods.Add("DrawRectangle", new Method( - name: "DrawRectangle", - description: LibrariesResources.GraphicsWindow_DrawRectangle, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawRectangle_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawRectangle_y) }, - { "width", new Parameter("width", LibrariesResources.GraphicsWindow_DrawRectangle_width) }, - { "height", new Parameter("height", LibrariesResources.GraphicsWindow_DrawRectangle_height) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.DrawResizedImage: - { - Task execute(SmallBasicEngine engine) - { - decimal height = engine.EvaluationStack.Pop().ToNumber(); - decimal width = engine.EvaluationStack.Pop().ToNumber(); - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - string imageName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.GraphicsWindow.DrawResizedImage(imageName: imageName, x: x, y: y, width: width, height: height); - return Task.CompletedTask; - } - - methods.Add("DrawResizedImage", new Method( - name: "DrawResizedImage", - description: LibrariesResources.GraphicsWindow_DrawResizedImage, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "imageName", new Parameter("imageName", LibrariesResources.GraphicsWindow_DrawResizedImage_imageName) }, - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawResizedImage_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawResizedImage_y) }, - { "width", new Parameter("width", LibrariesResources.GraphicsWindow_DrawResizedImage_width) }, - { "height", new Parameter("height", LibrariesResources.GraphicsWindow_DrawResizedImage_height) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.DrawText: - { - Task execute(SmallBasicEngine engine) - { - string text = engine.EvaluationStack.Pop().ToString(); - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.DrawText(x: x, y: y, text: text); - return Task.CompletedTask; - } - - methods.Add("DrawText", new Method( - name: "DrawText", - description: LibrariesResources.GraphicsWindow_DrawText, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawText_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawText_y) }, - { "text", new Parameter("text", LibrariesResources.GraphicsWindow_DrawText_text) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.DrawTriangle: - { - Task execute(SmallBasicEngine engine) - { - decimal y3 = engine.EvaluationStack.Pop().ToNumber(); - decimal x3 = engine.EvaluationStack.Pop().ToNumber(); - decimal y2 = engine.EvaluationStack.Pop().ToNumber(); - decimal x2 = engine.EvaluationStack.Pop().ToNumber(); - decimal y1 = engine.EvaluationStack.Pop().ToNumber(); - decimal x1 = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.DrawTriangle(x1: x1, y1: y1, x2: x2, y2: y2, x3: x3, y3: y3); - return Task.CompletedTask; - } - - methods.Add("DrawTriangle", new Method( - name: "DrawTriangle", - description: LibrariesResources.GraphicsWindow_DrawTriangle, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x1", new Parameter("x1", LibrariesResources.GraphicsWindow_DrawTriangle_x1) }, - { "y1", new Parameter("y1", LibrariesResources.GraphicsWindow_DrawTriangle_y1) }, - { "x2", new Parameter("x2", LibrariesResources.GraphicsWindow_DrawTriangle_x2) }, - { "y2", new Parameter("y2", LibrariesResources.GraphicsWindow_DrawTriangle_y2) }, - { "x3", new Parameter("x3", LibrariesResources.GraphicsWindow_DrawTriangle_x3) }, - { "y3", new Parameter("y3", LibrariesResources.GraphicsWindow_DrawTriangle_y3) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.FillEllipse: - { - Task execute(SmallBasicEngine engine) - { - decimal height = engine.EvaluationStack.Pop().ToNumber(); - decimal width = engine.EvaluationStack.Pop().ToNumber(); - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.FillEllipse(x: x, y: y, width: width, height: height); - return Task.CompletedTask; - } - - methods.Add("FillEllipse", new Method( - name: "FillEllipse", - description: LibrariesResources.GraphicsWindow_FillEllipse, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_FillEllipse_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_FillEllipse_y) }, - { "width", new Parameter("width", LibrariesResources.GraphicsWindow_FillEllipse_width) }, - { "height", new Parameter("height", LibrariesResources.GraphicsWindow_FillEllipse_height) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.FillRectangle: - { - Task execute(SmallBasicEngine engine) - { - decimal height = engine.EvaluationStack.Pop().ToNumber(); - decimal width = engine.EvaluationStack.Pop().ToNumber(); - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.FillRectangle(x: x, y: y, width: width, height: height); - return Task.CompletedTask; - } - - methods.Add("FillRectangle", new Method( - name: "FillRectangle", - description: LibrariesResources.GraphicsWindow_FillRectangle, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_FillRectangle_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_FillRectangle_y) }, - { "width", new Parameter("width", LibrariesResources.GraphicsWindow_FillRectangle_width) }, - { "height", new Parameter("height", LibrariesResources.GraphicsWindow_FillRectangle_height) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.FillTriangle: - { - Task execute(SmallBasicEngine engine) - { - decimal y3 = engine.EvaluationStack.Pop().ToNumber(); - decimal x3 = engine.EvaluationStack.Pop().ToNumber(); - decimal y2 = engine.EvaluationStack.Pop().ToNumber(); - decimal x2 = engine.EvaluationStack.Pop().ToNumber(); - decimal y1 = engine.EvaluationStack.Pop().ToNumber(); - decimal x1 = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.FillTriangle(x1: x1, y1: y1, x2: x2, y2: y2, x3: x3, y3: y3); - return Task.CompletedTask; - } - - methods.Add("FillTriangle", new Method( - name: "FillTriangle", - description: LibrariesResources.GraphicsWindow_FillTriangle, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x1", new Parameter("x1", LibrariesResources.GraphicsWindow_FillTriangle_x1) }, - { "y1", new Parameter("y1", LibrariesResources.GraphicsWindow_FillTriangle_y1) }, - { "x2", new Parameter("x2", LibrariesResources.GraphicsWindow_FillTriangle_x2) }, - { "y2", new Parameter("y2", LibrariesResources.GraphicsWindow_FillTriangle_y2) }, - { "x3", new Parameter("x3", LibrariesResources.GraphicsWindow_FillTriangle_x3) }, - { "y3", new Parameter("y3", LibrariesResources.GraphicsWindow_FillTriangle_y3) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.GetColorFromRGB: - { - Task execute(SmallBasicEngine engine) - { - decimal blue = engine.EvaluationStack.Pop().ToNumber(); - decimal green = engine.EvaluationStack.Pop().ToNumber(); - decimal red = engine.EvaluationStack.Pop().ToNumber(); - string returnValue = engine.Libraries.GraphicsWindow.GetColorFromRGB(red: red, green: green, blue: blue); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetColorFromRGB", new Method( - name: "GetColorFromRGB", - description: LibrariesResources.GraphicsWindow_GetColorFromRGB, - returnsValue: true, - returnValueDescription: LibrariesResources.GraphicsWindow_GetColorFromRGB_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "red", new Parameter("red", LibrariesResources.GraphicsWindow_GetColorFromRGB_red) }, - { "green", new Parameter("green", LibrariesResources.GraphicsWindow_GetColorFromRGB_green) }, - { "blue", new Parameter("blue", LibrariesResources.GraphicsWindow_GetColorFromRGB_blue) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.GetPixel: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'GraphicsWindow.GetPixel' is deprecated."); - } - - methods.Add("GetPixel", new Method( - name: "GetPixel", - description: LibrariesResources.GraphicsWindow_GetPixel, - returnsValue: true, - returnValueDescription: LibrariesResources.GraphicsWindow_GetPixel_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_GetPixel_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_GetPixel_y) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.GetRandomColor: - { - Task execute(SmallBasicEngine engine) - { - string returnValue = engine.Libraries.GraphicsWindow.GetRandomColor(); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetRandomColor", new Method( - name: "GetRandomColor", - description: LibrariesResources.GraphicsWindow_GetRandomColor, - returnsValue: true, - returnValueDescription: LibrariesResources.GraphicsWindow_GetRandomColor_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.Hide: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.GraphicsWindow.Hide(); - return Task.CompletedTask; - } - - methods.Add("Hide", new Method( - name: "Hide", - description: LibrariesResources.GraphicsWindow_Hide, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.SetPixel: - { - Task execute(SmallBasicEngine engine) - { - string color = engine.EvaluationStack.Pop().ToString(); - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.SetPixel(x: x, y: y, color: color); - return Task.CompletedTask; - } - - methods.Add("SetPixel", new Method( - name: "SetPixel", - description: LibrariesResources.GraphicsWindow_SetPixel, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x", new Parameter("x", LibrariesResources.GraphicsWindow_SetPixel_x) }, - { "y", new Parameter("y", LibrariesResources.GraphicsWindow_SetPixel_y) }, - { "color", new Parameter("color", LibrariesResources.GraphicsWindow_SetPixel_color) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.Show: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.GraphicsWindow.Show(); - return Task.CompletedTask; - } - - methods.Add("Show", new Method( - name: "Show", - description: LibrariesResources.GraphicsWindow_Show, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method GraphicsWindow.ShowMessage: - { - Task execute(SmallBasicEngine engine) - { - string title = engine.EvaluationStack.Pop().ToString(); - string text = engine.EvaluationStack.Pop().ToString(); - return engine.Libraries.GraphicsWindow.ShowMessage(text: text, title: title); - } - - methods.Add("ShowMessage", new Method( - name: "ShowMessage", - description: LibrariesResources.GraphicsWindow_ShowMessage, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.GraphicsWindow_ShowMessage_text) }, - { "title", new Parameter("title", LibrariesResources.GraphicsWindow_ShowMessage_title) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property GraphicsWindow.BackgroundColor: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.GraphicsWindow.Get_BackgroundColor(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.GraphicsWindow.Set_BackgroundColor(value); - return Task.CompletedTask; - } - - properties.Add("BackgroundColor", new Property("BackgroundColor", LibrariesResources.GraphicsWindow_BackgroundColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.BrushColor: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.GraphicsWindow.Get_BrushColor(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.GraphicsWindow.Set_BrushColor(value); - return Task.CompletedTask; - } - - properties.Add("BrushColor", new Property("BrushColor", LibrariesResources.GraphicsWindow_BrushColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.CanResize: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'GraphicsWindow.CanResize' is deprecated."); - } - - Task setter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'GraphicsWindow.CanResize' is deprecated."); - } - - properties.Add("CanResize", new Property("CanResize", LibrariesResources.GraphicsWindow_CanResize, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.FontBold: - { - Task getter(SmallBasicEngine engine) - { - bool value = engine.Libraries.GraphicsWindow.Get_FontBold(); - engine.EvaluationStack.Push(new BooleanValue(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - bool value = engine.EvaluationStack.Pop().ToBoolean(); - engine.Libraries.GraphicsWindow.Set_FontBold(value); - return Task.CompletedTask; - } - - properties.Add("FontBold", new Property("FontBold", LibrariesResources.GraphicsWindow_FontBold, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.FontItalic: - { - Task getter(SmallBasicEngine engine) - { - bool value = engine.Libraries.GraphicsWindow.Get_FontItalic(); - engine.EvaluationStack.Push(new BooleanValue(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - bool value = engine.EvaluationStack.Pop().ToBoolean(); - engine.Libraries.GraphicsWindow.Set_FontItalic(value); - return Task.CompletedTask; - } - - properties.Add("FontItalic", new Property("FontItalic", LibrariesResources.GraphicsWindow_FontItalic, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.FontName: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.GraphicsWindow.Get_FontName(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.GraphicsWindow.Set_FontName(value); - return Task.CompletedTask; - } - - properties.Add("FontName", new Property("FontName", LibrariesResources.GraphicsWindow_FontName, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.FontSize: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.GraphicsWindow.Get_FontSize(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - decimal value = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.Set_FontSize(value); - return Task.CompletedTask; - } - - properties.Add("FontSize", new Property("FontSize", LibrariesResources.GraphicsWindow_FontSize, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.Height: - { - async Task getter(SmallBasicEngine engine) - { - decimal value = await engine.Libraries.GraphicsWindow.Get_Height().ConfigureAwait(false); - engine.EvaluationStack.Push(new NumberValue(value)); - } - - Task setter(SmallBasicEngine engine) - { - decimal value = engine.EvaluationStack.Pop().ToNumber(); - return engine.Libraries.GraphicsWindow.Set_Height(value); - } - - properties.Add("Height", new Property("Height", LibrariesResources.GraphicsWindow_Height, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.LastKey: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.GraphicsWindow.Get_LastKey(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - properties.Add("LastKey", new Property("LastKey", LibrariesResources.GraphicsWindow_LastKey, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property GraphicsWindow.LastText: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.GraphicsWindow.Get_LastText(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - properties.Add("LastText", new Property("LastText", LibrariesResources.GraphicsWindow_LastText, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property GraphicsWindow.Left: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'GraphicsWindow.Left' is deprecated."); - } - - Task setter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'GraphicsWindow.Left' is deprecated."); - } - - properties.Add("Left", new Property("Left", LibrariesResources.GraphicsWindow_Left, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.MouseX: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.GraphicsWindow.Get_MouseX(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("MouseX", new Property("MouseX", LibrariesResources.GraphicsWindow_MouseX, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property GraphicsWindow.MouseY: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.GraphicsWindow.Get_MouseY(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("MouseY", new Property("MouseY", LibrariesResources.GraphicsWindow_MouseY, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property GraphicsWindow.PenColor: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.GraphicsWindow.Get_PenColor(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.GraphicsWindow.Set_PenColor(value); - return Task.CompletedTask; - } - - properties.Add("PenColor", new Property("PenColor", LibrariesResources.GraphicsWindow_PenColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.PenWidth: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.GraphicsWindow.Get_PenWidth(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - decimal value = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.GraphicsWindow.Set_PenWidth(value); - return Task.CompletedTask; - } - - properties.Add("PenWidth", new Property("PenWidth", LibrariesResources.GraphicsWindow_PenWidth, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.Title: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.GraphicsWindow.Get_Title(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.GraphicsWindow.Set_Title(value); - return Task.CompletedTask; - } - - properties.Add("Title", new Property("Title", LibrariesResources.GraphicsWindow_Title, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.Top: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'GraphicsWindow.Top' is deprecated."); - } - - Task setter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'GraphicsWindow.Top' is deprecated."); - } - - properties.Add("Top", new Property("Top", LibrariesResources.GraphicsWindow_Top, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property GraphicsWindow.Width: - { - async Task getter(SmallBasicEngine engine) - { - decimal value = await engine.Libraries.GraphicsWindow.Get_Width().ConfigureAwait(false); - engine.EvaluationStack.Push(new NumberValue(value)); - } - - Task setter(SmallBasicEngine engine) - { - decimal value = engine.EvaluationStack.Pop().ToNumber(); - return engine.Libraries.GraphicsWindow.Set_Width(value); - } - - properties.Add("Width", new Property("Width", LibrariesResources.GraphicsWindow_Width, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "KeyDown", new Event("KeyDown", LibrariesResources.GraphicsWindow_KeyDown) }, - { "KeyUp", new Event("KeyUp", LibrariesResources.GraphicsWindow_KeyUp) }, - { "MouseDown", new Event("MouseDown", LibrariesResources.GraphicsWindow_MouseDown) }, - { "MouseMove", new Event("MouseMove", LibrariesResources.GraphicsWindow_MouseMove) }, - { "MouseUp", new Event("MouseUp", LibrariesResources.GraphicsWindow_MouseUp) }, - { "TextInput", new Event("TextInput", LibrariesResources.GraphicsWindow_TextInput) }, - }; - - types.Add("GraphicsWindow", new Library("GraphicsWindow", LibrariesResources.GraphicsWindow, "paint-brush", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'ImageList' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method ImageList.GetHeightOfImage: - { - Task execute(SmallBasicEngine engine) - { - string imageName = engine.EvaluationStack.Pop().ToString(); - decimal returnValue = engine.Libraries.ImageList.GetHeightOfImage(imageName: imageName); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetHeightOfImage", new Method( - name: "GetHeightOfImage", - description: LibrariesResources.ImageList_GetHeightOfImage, - returnsValue: true, - returnValueDescription: LibrariesResources.ImageList_GetHeightOfImage_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "imageName", new Parameter("imageName", LibrariesResources.ImageList_GetHeightOfImage_imageName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method ImageList.GetWidthOfImage: - { - Task execute(SmallBasicEngine engine) - { - string imageName = engine.EvaluationStack.Pop().ToString(); - decimal returnValue = engine.Libraries.ImageList.GetWidthOfImage(imageName: imageName); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetWidthOfImage", new Method( - name: "GetWidthOfImage", - description: LibrariesResources.ImageList_GetWidthOfImage, - returnsValue: true, - returnValueDescription: LibrariesResources.ImageList_GetWidthOfImage_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "imageName", new Parameter("imageName", LibrariesResources.ImageList_GetWidthOfImage_imageName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method ImageList.LoadImage: - { - async Task execute(SmallBasicEngine engine) - { - string fileNameOrUrl = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.ImageList.LoadImage(fileNameOrUrl: fileNameOrUrl).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("LoadImage", new Method( - name: "LoadImage", - description: LibrariesResources.ImageList_LoadImage, - returnsValue: true, - returnValueDescription: LibrariesResources.ImageList_LoadImage_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "fileNameOrUrl", new Parameter("fileNameOrUrl", LibrariesResources.ImageList_LoadImage_fileNameOrUrl) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("ImageList", new Library("ImageList", LibrariesResources.ImageList, "images", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Math' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Math.Abs: - { - Task execute(SmallBasicEngine engine) - { - decimal number = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Abs(number: number); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Abs", new Method( - name: "Abs", - description: LibrariesResources.Math_Abs, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Abs_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "number", new Parameter("number", LibrariesResources.Math_Abs_number) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.ArcCos: - { - Task execute(SmallBasicEngine engine) - { - decimal cosValue = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.ArcCos(cosValue: cosValue); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("ArcCos", new Method( - name: "ArcCos", - description: LibrariesResources.Math_ArcCos, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_ArcCos_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "cosValue", new Parameter("cosValue", LibrariesResources.Math_ArcCos_cosValue) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.ArcSin: - { - Task execute(SmallBasicEngine engine) - { - decimal sinValue = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.ArcSin(sinValue: sinValue); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("ArcSin", new Method( - name: "ArcSin", - description: LibrariesResources.Math_ArcSin, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_ArcSin_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "sinValue", new Parameter("sinValue", LibrariesResources.Math_ArcSin_sinValue) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.ArcTan: - { - Task execute(SmallBasicEngine engine) - { - decimal tanValue = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.ArcTan(tanValue: tanValue); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("ArcTan", new Method( - name: "ArcTan", - description: LibrariesResources.Math_ArcTan, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_ArcTan_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "tanValue", new Parameter("tanValue", LibrariesResources.Math_ArcTan_tanValue) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Ceiling: - { - Task execute(SmallBasicEngine engine) - { - decimal number = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Ceiling(number: number); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Ceiling", new Method( - name: "Ceiling", - description: LibrariesResources.Math_Ceiling, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Ceiling_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "number", new Parameter("number", LibrariesResources.Math_Ceiling_number) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Cos: - { - Task execute(SmallBasicEngine engine) - { - decimal angle = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Cos(angle: angle); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Cos", new Method( - name: "Cos", - description: LibrariesResources.Math_Cos, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Cos_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "angle", new Parameter("angle", LibrariesResources.Math_Cos_angle) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Floor: - { - Task execute(SmallBasicEngine engine) - { - decimal number = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Floor(number: number); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Floor", new Method( - name: "Floor", - description: LibrariesResources.Math_Floor, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Floor_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "number", new Parameter("number", LibrariesResources.Math_Floor_number) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.GetDegrees: - { - Task execute(SmallBasicEngine engine) - { - decimal angle = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.GetDegrees(angle: angle); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetDegrees", new Method( - name: "GetDegrees", - description: LibrariesResources.Math_GetDegrees, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_GetDegrees_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "angle", new Parameter("angle", LibrariesResources.Math_GetDegrees_angle) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.GetRadians: - { - Task execute(SmallBasicEngine engine) - { - decimal angle = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.GetRadians(angle: angle); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetRadians", new Method( - name: "GetRadians", - description: LibrariesResources.Math_GetRadians, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_GetRadians_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "angle", new Parameter("angle", LibrariesResources.Math_GetRadians_angle) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.GetRandomNumber: - { - Task execute(SmallBasicEngine engine) - { - decimal maxNumber = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.GetRandomNumber(maxNumber: maxNumber); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetRandomNumber", new Method( - name: "GetRandomNumber", - description: LibrariesResources.Math_GetRandomNumber, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_GetRandomNumber_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "maxNumber", new Parameter("maxNumber", LibrariesResources.Math_GetRandomNumber_maxNumber) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Log: - { - Task execute(SmallBasicEngine engine) - { - decimal number = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Log(number: number); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Log", new Method( - name: "Log", - description: LibrariesResources.Math_Log, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Log_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "number", new Parameter("number", LibrariesResources.Math_Log_number) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Max: - { - Task execute(SmallBasicEngine engine) - { - decimal number2 = engine.EvaluationStack.Pop().ToNumber(); - decimal number1 = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Max(number1: number1, number2: number2); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Max", new Method( - name: "Max", - description: LibrariesResources.Math_Max, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Max_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "number1", new Parameter("number1", LibrariesResources.Math_Max_number1) }, - { "number2", new Parameter("number2", LibrariesResources.Math_Max_number2) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Min: - { - Task execute(SmallBasicEngine engine) - { - decimal number2 = engine.EvaluationStack.Pop().ToNumber(); - decimal number1 = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Min(number1: number1, number2: number2); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Min", new Method( - name: "Min", - description: LibrariesResources.Math_Min, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Min_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "number1", new Parameter("number1", LibrariesResources.Math_Min_number1) }, - { "number2", new Parameter("number2", LibrariesResources.Math_Min_number2) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.NaturalLog: - { - Task execute(SmallBasicEngine engine) - { - decimal number = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.NaturalLog(number: number); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("NaturalLog", new Method( - name: "NaturalLog", - description: LibrariesResources.Math_NaturalLog, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_NaturalLog_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "number", new Parameter("number", LibrariesResources.Math_NaturalLog_number) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Power: - { - Task execute(SmallBasicEngine engine) - { - decimal exponent = engine.EvaluationStack.Pop().ToNumber(); - decimal baseNumber = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Power(baseNumber: baseNumber, exponent: exponent); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Power", new Method( - name: "Power", - description: LibrariesResources.Math_Power, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Power_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "baseNumber", new Parameter("baseNumber", LibrariesResources.Math_Power_baseNumber) }, - { "exponent", new Parameter("exponent", LibrariesResources.Math_Power_exponent) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Remainder: - { - Task execute(SmallBasicEngine engine) - { - decimal divisor = engine.EvaluationStack.Pop().ToNumber(); - decimal dividend = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Remainder(dividend: dividend, divisor: divisor); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Remainder", new Method( - name: "Remainder", - description: LibrariesResources.Math_Remainder, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Remainder_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "dividend", new Parameter("dividend", LibrariesResources.Math_Remainder_dividend) }, - { "divisor", new Parameter("divisor", LibrariesResources.Math_Remainder_divisor) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Round: - { - Task execute(SmallBasicEngine engine) - { - decimal number = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Round(number: number); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Round", new Method( - name: "Round", - description: LibrariesResources.Math_Round, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Round_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "number", new Parameter("number", LibrariesResources.Math_Round_number) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Sin: - { - Task execute(SmallBasicEngine engine) - { - decimal angle = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Sin(angle: angle); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Sin", new Method( - name: "Sin", - description: LibrariesResources.Math_Sin, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Sin_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "angle", new Parameter("angle", LibrariesResources.Math_Sin_angle) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.SquareRoot: - { - Task execute(SmallBasicEngine engine) - { - decimal number = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.SquareRoot(number: number); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("SquareRoot", new Method( - name: "SquareRoot", - description: LibrariesResources.Math_SquareRoot, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_SquareRoot_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "number", new Parameter("number", LibrariesResources.Math_SquareRoot_number) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Math.Tan: - { - Task execute(SmallBasicEngine engine) - { - decimal angle = engine.EvaluationStack.Pop().ToNumber(); - decimal returnValue = engine.Libraries.Math.Tan(angle: angle); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Tan", new Method( - name: "Tan", - description: LibrariesResources.Math_Tan, - returnsValue: true, - returnValueDescription: LibrariesResources.Math_Tan_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "angle", new Parameter("angle", LibrariesResources.Math_Tan_angle) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property Math.Pi: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Math.Get_Pi(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("Pi", new Property("Pi", LibrariesResources.Math_Pi, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Math", new Library("Math", LibrariesResources.Math, "calculator", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Mouse' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Mouse.HideCursor: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Mouse.HideCursor(); - return Task.CompletedTask; - } - - methods.Add("HideCursor", new Method( - name: "HideCursor", - description: LibrariesResources.Mouse_HideCursor, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Mouse.ShowCursor: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Mouse.ShowCursor(); - return Task.CompletedTask; - } - - methods.Add("ShowCursor", new Method( - name: "ShowCursor", - description: LibrariesResources.Mouse_ShowCursor, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property Mouse.IsLeftButtonDown: - { - Task getter(SmallBasicEngine engine) - { - bool value = engine.Libraries.Mouse.Get_IsLeftButtonDown(); - engine.EvaluationStack.Push(new BooleanValue(value)); - return Task.CompletedTask; - } - - properties.Add("IsLeftButtonDown", new Property("IsLeftButtonDown", LibrariesResources.Mouse_IsLeftButtonDown, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Mouse.IsRightButtonDown: - { - Task getter(SmallBasicEngine engine) - { - bool value = engine.Libraries.Mouse.Get_IsRightButtonDown(); - engine.EvaluationStack.Push(new BooleanValue(value)); - return Task.CompletedTask; - } - - properties.Add("IsRightButtonDown", new Property("IsRightButtonDown", LibrariesResources.Mouse_IsRightButtonDown, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Mouse.MouseX: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Mouse.Get_MouseX(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("MouseX", new Property("MouseX", LibrariesResources.Mouse_MouseX, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Mouse.MouseY: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Mouse.Get_MouseY(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - properties.Add("MouseY", new Property("MouseY", LibrariesResources.Mouse_MouseY, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Mouse", new Library("Mouse", LibrariesResources.Mouse, "mouse-pointer", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Network' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Network.DownloadFile: - { - async Task execute(SmallBasicEngine engine) - { - string url = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.Network.DownloadFile(url: url).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("DownloadFile", new Method( - name: "DownloadFile", - description: LibrariesResources.Network_DownloadFile, - returnsValue: true, - returnValueDescription: LibrariesResources.Network_DownloadFile_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "url", new Parameter("url", LibrariesResources.Network_DownloadFile_url) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - // Initialization code for method Network.GetWebPageContents: - { - async Task execute(SmallBasicEngine engine) - { - string url = engine.EvaluationStack.Pop().ToString(); - string returnValue = await engine.Libraries.Network.GetWebPageContents(url: url).ConfigureAwait(false); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - } - - methods.Add("GetWebPageContents", new Method( - name: "GetWebPageContents", - description: LibrariesResources.Network_GetWebPageContents, - returnsValue: true, - returnValueDescription: LibrariesResources.Network_GetWebPageContents_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "url", new Parameter("url", LibrariesResources.Network_GetWebPageContents_url) }, - }, - isDeprecated: false, - needsDesktop: true, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Network", new Library("Network", LibrariesResources.Network, "network-wired", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Program' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Program.Delay: - { - Task execute(SmallBasicEngine engine) - { - decimal milliSeconds = engine.EvaluationStack.Pop().ToNumber(); - return engine.Libraries.Program.Delay(milliSeconds: milliSeconds); - } - - methods.Add("Delay", new Method( - name: "Delay", - description: LibrariesResources.Program_Delay, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "milliSeconds", new Parameter("milliSeconds", LibrariesResources.Program_Delay_milliSeconds) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Program.End: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Program.End(); - return Task.CompletedTask; - } - - methods.Add("End", new Method( - name: "End", - description: LibrariesResources.Program_End, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Program.GetArgument: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Program.GetArgument' is deprecated."); - } - - methods.Add("GetArgument", new Method( - name: "GetArgument", - description: LibrariesResources.Program_GetArgument, - returnsValue: true, - returnValueDescription: LibrariesResources.Program_GetArgument_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "index", new Parameter("index", LibrariesResources.Program_GetArgument_index) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Program.Pause: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Program.Pause(); - return Task.CompletedTask; - } - - methods.Add("Pause", new Method( - name: "Pause", - description: LibrariesResources.Program_Pause, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property Program.ArgumentCount: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'Program.ArgumentCount' is deprecated."); - } - - properties.Add("ArgumentCount", new Property("ArgumentCount", LibrariesResources.Program_ArgumentCount, isDeprecated: true, needsDesktop: false, getter: getter, setter: null)); - } - - // Initialization code for property Program.Directory: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'Program.Directory' is deprecated."); - } - - properties.Add("Directory", new Property("Directory", LibrariesResources.Program_Directory, isDeprecated: true, needsDesktop: false, getter: getter, setter: null)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Program", new Library("Program", LibrariesResources.Program, "laptop-code", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Shapes' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Shapes.AddEllipse: - { - Task execute(SmallBasicEngine engine) - { - decimal height = engine.EvaluationStack.Pop().ToNumber(); - decimal width = engine.EvaluationStack.Pop().ToNumber(); - string returnValue = engine.Libraries.Shapes.AddEllipse(width: width, height: height); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("AddEllipse", new Method( - name: "AddEllipse", - description: LibrariesResources.Shapes_AddEllipse, - returnsValue: true, - returnValueDescription: LibrariesResources.Shapes_AddEllipse_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "width", new Parameter("width", LibrariesResources.Shapes_AddEllipse_width) }, - { "height", new Parameter("height", LibrariesResources.Shapes_AddEllipse_height) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.AddImage: - { - Task execute(SmallBasicEngine engine) - { - string imageName = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Shapes.AddImage(imageName: imageName); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("AddImage", new Method( - name: "AddImage", - description: LibrariesResources.Shapes_AddImage, - returnsValue: true, - returnValueDescription: LibrariesResources.Shapes_AddImage_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "imageName", new Parameter("imageName", LibrariesResources.Shapes_AddImage_imageName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.AddLine: - { - Task execute(SmallBasicEngine engine) - { - decimal y2 = engine.EvaluationStack.Pop().ToNumber(); - decimal x2 = engine.EvaluationStack.Pop().ToNumber(); - decimal y1 = engine.EvaluationStack.Pop().ToNumber(); - decimal x1 = engine.EvaluationStack.Pop().ToNumber(); - string returnValue = engine.Libraries.Shapes.AddLine(x1: x1, y1: y1, x2: x2, y2: y2); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("AddLine", new Method( - name: "AddLine", - description: LibrariesResources.Shapes_AddLine, - returnsValue: true, - returnValueDescription: LibrariesResources.Shapes_AddLine_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x1", new Parameter("x1", LibrariesResources.Shapes_AddLine_x1) }, - { "y1", new Parameter("y1", LibrariesResources.Shapes_AddLine_y1) }, - { "x2", new Parameter("x2", LibrariesResources.Shapes_AddLine_x2) }, - { "y2", new Parameter("y2", LibrariesResources.Shapes_AddLine_y2) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.AddRectangle: - { - Task execute(SmallBasicEngine engine) - { - decimal height = engine.EvaluationStack.Pop().ToNumber(); - decimal width = engine.EvaluationStack.Pop().ToNumber(); - string returnValue = engine.Libraries.Shapes.AddRectangle(width: width, height: height); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("AddRectangle", new Method( - name: "AddRectangle", - description: LibrariesResources.Shapes_AddRectangle, - returnsValue: true, - returnValueDescription: LibrariesResources.Shapes_AddRectangle_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "width", new Parameter("width", LibrariesResources.Shapes_AddRectangle_width) }, - { "height", new Parameter("height", LibrariesResources.Shapes_AddRectangle_height) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.AddText: - { - Task execute(SmallBasicEngine engine) - { - string text = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Shapes.AddText(text: text); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("AddText", new Method( - name: "AddText", - description: LibrariesResources.Shapes_AddText, - returnsValue: true, - returnValueDescription: LibrariesResources.Shapes_AddText_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Shapes_AddText_text) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.AddTriangle: - { - Task execute(SmallBasicEngine engine) - { - decimal y3 = engine.EvaluationStack.Pop().ToNumber(); - decimal x3 = engine.EvaluationStack.Pop().ToNumber(); - decimal y2 = engine.EvaluationStack.Pop().ToNumber(); - decimal x2 = engine.EvaluationStack.Pop().ToNumber(); - decimal y1 = engine.EvaluationStack.Pop().ToNumber(); - decimal x1 = engine.EvaluationStack.Pop().ToNumber(); - string returnValue = engine.Libraries.Shapes.AddTriangle(x1: x1, y1: y1, x2: x2, y2: y2, x3: x3, y3: y3); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("AddTriangle", new Method( - name: "AddTriangle", - description: LibrariesResources.Shapes_AddTriangle, - returnsValue: true, - returnValueDescription: LibrariesResources.Shapes_AddTriangle_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x1", new Parameter("x1", LibrariesResources.Shapes_AddTriangle_x1) }, - { "y1", new Parameter("y1", LibrariesResources.Shapes_AddTriangle_y1) }, - { "x2", new Parameter("x2", LibrariesResources.Shapes_AddTriangle_x2) }, - { "y2", new Parameter("y2", LibrariesResources.Shapes_AddTriangle_y2) }, - { "x3", new Parameter("x3", LibrariesResources.Shapes_AddTriangle_x3) }, - { "y3", new Parameter("y3", LibrariesResources.Shapes_AddTriangle_y3) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.Animate: - { - Task execute(SmallBasicEngine engine) - { - decimal duration = engine.EvaluationStack.Pop().ToNumber(); - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - string shapeName = engine.EvaluationStack.Pop().ToString(); - return engine.Libraries.Shapes.Animate(shapeName: shapeName, x: x, y: y, duration: duration); - } - - methods.Add("Animate", new Method( - name: "Animate", - description: LibrariesResources.Shapes_Animate, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Animate_shapeName) }, - { "x", new Parameter("x", LibrariesResources.Shapes_Animate_x) }, - { "y", new Parameter("y", LibrariesResources.Shapes_Animate_y) }, - { "duration", new Parameter("duration", LibrariesResources.Shapes_Animate_duration) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.GetLeft: - { - Task execute(SmallBasicEngine engine) - { - string shapeName = engine.EvaluationStack.Pop().ToString(); - decimal returnValue = engine.Libraries.Shapes.GetLeft(shapeName: shapeName); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetLeft", new Method( - name: "GetLeft", - description: LibrariesResources.Shapes_GetLeft, - returnsValue: true, - returnValueDescription: LibrariesResources.Shapes_GetLeft_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_GetLeft_shapeName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.GetOpacity: - { - Task execute(SmallBasicEngine engine) - { - string shapeName = engine.EvaluationStack.Pop().ToString(); - decimal returnValue = engine.Libraries.Shapes.GetOpacity(shapeName: shapeName); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetOpacity", new Method( - name: "GetOpacity", - description: LibrariesResources.Shapes_GetOpacity, - returnsValue: true, - returnValueDescription: LibrariesResources.Shapes_GetOpacity_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_GetOpacity_shapeName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.GetTop: - { - Task execute(SmallBasicEngine engine) - { - string shapeName = engine.EvaluationStack.Pop().ToString(); - decimal returnValue = engine.Libraries.Shapes.GetTop(shapeName: shapeName); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetTop", new Method( - name: "GetTop", - description: LibrariesResources.Shapes_GetTop, - returnsValue: true, - returnValueDescription: LibrariesResources.Shapes_GetTop_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_GetTop_shapeName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.HideShape: - { - Task execute(SmallBasicEngine engine) - { - string shapeName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Shapes.HideShape(shapeName: shapeName); - return Task.CompletedTask; - } - - methods.Add("HideShape", new Method( - name: "HideShape", - description: LibrariesResources.Shapes_HideShape, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_HideShape_shapeName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.Move: - { - Task execute(SmallBasicEngine engine) - { - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - string shapeName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Shapes.Move(shapeName: shapeName, x: x, y: y); - return Task.CompletedTask; - } - - methods.Add("Move", new Method( - name: "Move", - description: LibrariesResources.Shapes_Move, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Move_shapeName) }, - { "x", new Parameter("x", LibrariesResources.Shapes_Move_x) }, - { "y", new Parameter("y", LibrariesResources.Shapes_Move_y) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.Remove: - { - Task execute(SmallBasicEngine engine) - { - string shapeName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Shapes.Remove(shapeName: shapeName); - return Task.CompletedTask; - } - - methods.Add("Remove", new Method( - name: "Remove", - description: LibrariesResources.Shapes_Remove, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Remove_shapeName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.Rotate: - { - Task execute(SmallBasicEngine engine) - { - decimal angle = engine.EvaluationStack.Pop().ToNumber(); - string shapeName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Shapes.Rotate(shapeName: shapeName, angle: angle); - return Task.CompletedTask; - } - - methods.Add("Rotate", new Method( - name: "Rotate", - description: LibrariesResources.Shapes_Rotate, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Rotate_shapeName) }, - { "angle", new Parameter("angle", LibrariesResources.Shapes_Rotate_angle) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.SetOpacity: - { - Task execute(SmallBasicEngine engine) - { - decimal level = engine.EvaluationStack.Pop().ToNumber(); - string shapeName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Shapes.SetOpacity(shapeName: shapeName, level: level); - return Task.CompletedTask; - } - - methods.Add("SetOpacity", new Method( - name: "SetOpacity", - description: LibrariesResources.Shapes_SetOpacity, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_SetOpacity_shapeName) }, - { "level", new Parameter("level", LibrariesResources.Shapes_SetOpacity_level) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.SetText: - { - Task execute(SmallBasicEngine engine) - { - string text = engine.EvaluationStack.Pop().ToString(); - string shapeName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Shapes.SetText(shapeName: shapeName, text: text); - return Task.CompletedTask; - } - - methods.Add("SetText", new Method( - name: "SetText", - description: LibrariesResources.Shapes_SetText, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_SetText_shapeName) }, - { "text", new Parameter("text", LibrariesResources.Shapes_SetText_text) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.ShowShape: - { - Task execute(SmallBasicEngine engine) - { - string shapeName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Shapes.ShowShape(shapeName: shapeName); - return Task.CompletedTask; - } - - methods.Add("ShowShape", new Method( - name: "ShowShape", - description: LibrariesResources.Shapes_ShowShape, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_ShowShape_shapeName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Shapes.Zoom: - { - Task execute(SmallBasicEngine engine) - { - decimal scaleY = engine.EvaluationStack.Pop().ToNumber(); - decimal scaleX = engine.EvaluationStack.Pop().ToNumber(); - string shapeName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Shapes.Zoom(shapeName: shapeName, scaleX: scaleX, scaleY: scaleY); - return Task.CompletedTask; - } - - methods.Add("Zoom", new Method( - name: "Zoom", - description: LibrariesResources.Shapes_Zoom, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Zoom_shapeName) }, - { "scaleX", new Parameter("scaleX", LibrariesResources.Shapes_Zoom_scaleX) }, - { "scaleY", new Parameter("scaleY", LibrariesResources.Shapes_Zoom_scaleY) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Shapes", new Library("Shapes", LibrariesResources.Shapes, "shapes", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Sound' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Sound.Pause: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.Pause' is deprecated."); - } - - methods.Add("Pause", new Method( - name: "Pause", - description: LibrariesResources.Sound_Pause, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.Sound_Pause_filePath) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.Play: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.Play' is deprecated."); - } - - methods.Add("Play", new Method( - name: "Play", - description: LibrariesResources.Sound_Play, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.Sound_Play_filePath) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayAndWait: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayAndWait' is deprecated."); - } - - methods.Add("PlayAndWait", new Method( - name: "PlayAndWait", - description: LibrariesResources.Sound_PlayAndWait, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.Sound_PlayAndWait_filePath) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayBellRing: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayBellRing' is deprecated."); - } - - methods.Add("PlayBellRing", new Method( - name: "PlayBellRing", - description: LibrariesResources.Sound_PlayBellRing, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayBellRingAndWait: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayBellRingAndWait' is deprecated."); - } - - methods.Add("PlayBellRingAndWait", new Method( - name: "PlayBellRingAndWait", - description: LibrariesResources.Sound_PlayBellRingAndWait, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayChime: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayChime' is deprecated."); - } - - methods.Add("PlayChime", new Method( - name: "PlayChime", - description: LibrariesResources.Sound_PlayChime, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayChimeAndWait: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayChimeAndWait' is deprecated."); - } - - methods.Add("PlayChimeAndWait", new Method( - name: "PlayChimeAndWait", - description: LibrariesResources.Sound_PlayChimeAndWait, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayChimes: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayChimes' is deprecated."); - } - - methods.Add("PlayChimes", new Method( - name: "PlayChimes", - description: LibrariesResources.Sound_PlayChimes, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayChimesAndWait: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayChimesAndWait' is deprecated."); - } - - methods.Add("PlayChimesAndWait", new Method( - name: "PlayChimesAndWait", - description: LibrariesResources.Sound_PlayChimesAndWait, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayClick: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayClick' is deprecated."); - } - - methods.Add("PlayClick", new Method( - name: "PlayClick", - description: LibrariesResources.Sound_PlayClick, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayClickAndWait: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayClickAndWait' is deprecated."); - } - - methods.Add("PlayClickAndWait", new Method( - name: "PlayClickAndWait", - description: LibrariesResources.Sound_PlayClickAndWait, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.PlayMusic: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.PlayMusic' is deprecated."); - } - - methods.Add("PlayMusic", new Method( - name: "PlayMusic", - description: LibrariesResources.Sound_PlayMusic, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "notes", new Parameter("notes", LibrariesResources.Sound_PlayMusic_notes) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Sound.Stop: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'Sound.Stop' is deprecated."); - } - - methods.Add("Stop", new Method( - name: "Stop", - description: LibrariesResources.Sound_Stop, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "filePath", new Parameter("filePath", LibrariesResources.Sound_Stop_filePath) }, - }, - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Sound", new Library("Sound", LibrariesResources.Sound, "volume-up", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Stack' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Stack.GetCount: - { - Task execute(SmallBasicEngine engine) - { - string stackName = engine.EvaluationStack.Pop().ToString(); - decimal returnValue = engine.Libraries.Stack.GetCount(stackName: stackName); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetCount", new Method( - name: "GetCount", - description: LibrariesResources.Stack_GetCount, - returnsValue: true, - returnValueDescription: LibrariesResources.Stack_GetCount_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "stackName", new Parameter("stackName", LibrariesResources.Stack_GetCount_stackName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Stack.PopValue: - { - Task execute(SmallBasicEngine engine) - { - string stackName = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Stack.PopValue(stackName: stackName); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("PopValue", new Method( - name: "PopValue", - description: LibrariesResources.Stack_PopValue, - returnsValue: true, - returnValueDescription: LibrariesResources.Stack_PopValue_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "stackName", new Parameter("stackName", LibrariesResources.Stack_PopValue_stackName) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Stack.PushValue: - { - Task execute(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - string stackName = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.Stack.PushValue(stackName: stackName, value: value); - return Task.CompletedTask; - } - - methods.Add("PushValue", new Method( - name: "PushValue", - description: LibrariesResources.Stack_PushValue, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "stackName", new Parameter("stackName", LibrariesResources.Stack_PushValue_stackName) }, - { "value", new Parameter("value", LibrariesResources.Stack_PushValue_value) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Stack", new Library("Stack", LibrariesResources.Stack, "ellipsis-v", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Text' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Text.Append: - { - Task execute(SmallBasicEngine engine) - { - string text2 = engine.EvaluationStack.Pop().ToString(); - string text1 = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Text.Append(text1: text1, text2: text2); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Append", new Method( - name: "Append", - description: LibrariesResources.Text_Append, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_Append_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text1", new Parameter("text1", LibrariesResources.Text_Append_text1) }, - { "text2", new Parameter("text2", LibrariesResources.Text_Append_text2) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.ConvertToLowerCase: - { - Task execute(SmallBasicEngine engine) - { - string text = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Text.ConvertToLowerCase(text: text); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("ConvertToLowerCase", new Method( - name: "ConvertToLowerCase", - description: LibrariesResources.Text_ConvertToLowerCase, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_ConvertToLowerCase_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Text_ConvertToLowerCase_text) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.ConvertToUpperCase: - { - Task execute(SmallBasicEngine engine) - { - string text = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Text.ConvertToUpperCase(text: text); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("ConvertToUpperCase", new Method( - name: "ConvertToUpperCase", - description: LibrariesResources.Text_ConvertToUpperCase, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_ConvertToUpperCase_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Text_ConvertToUpperCase_text) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.EndsWith: - { - Task execute(SmallBasicEngine engine) - { - string subText = engine.EvaluationStack.Pop().ToString(); - string text = engine.EvaluationStack.Pop().ToString(); - bool returnValue = engine.Libraries.Text.EndsWith(text: text, subText: subText); - engine.EvaluationStack.Push(new BooleanValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("EndsWith", new Method( - name: "EndsWith", - description: LibrariesResources.Text_EndsWith, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_EndsWith_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Text_EndsWith_text) }, - { "subText", new Parameter("subText", LibrariesResources.Text_EndsWith_subText) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.GetCharacter: - { - Task execute(SmallBasicEngine engine) - { - decimal characterCode = engine.EvaluationStack.Pop().ToNumber(); - string returnValue = engine.Libraries.Text.GetCharacter(characterCode: characterCode); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetCharacter", new Method( - name: "GetCharacter", - description: LibrariesResources.Text_GetCharacter, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_GetCharacter_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "characterCode", new Parameter("characterCode", LibrariesResources.Text_GetCharacter_characterCode) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.GetCharacterCode: - { - Task execute(SmallBasicEngine engine) - { - string character = engine.EvaluationStack.Pop().ToString(); - decimal returnValue = engine.Libraries.Text.GetCharacterCode(character: character); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetCharacterCode", new Method( - name: "GetCharacterCode", - description: LibrariesResources.Text_GetCharacterCode, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_GetCharacterCode_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "character", new Parameter("character", LibrariesResources.Text_GetCharacterCode_character) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.GetIndexOf: - { - Task execute(SmallBasicEngine engine) - { - string subText = engine.EvaluationStack.Pop().ToString(); - string text = engine.EvaluationStack.Pop().ToString(); - decimal returnValue = engine.Libraries.Text.GetIndexOf(text: text, subText: subText); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetIndexOf", new Method( - name: "GetIndexOf", - description: LibrariesResources.Text_GetIndexOf, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_GetIndexOf_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Text_GetIndexOf_text) }, - { "subText", new Parameter("subText", LibrariesResources.Text_GetIndexOf_subText) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.GetLength: - { - Task execute(SmallBasicEngine engine) - { - string text = engine.EvaluationStack.Pop().ToString(); - decimal returnValue = engine.Libraries.Text.GetLength(text: text); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetLength", new Method( - name: "GetLength", - description: LibrariesResources.Text_GetLength, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_GetLength_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Text_GetLength_text) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.GetSubText: - { - Task execute(SmallBasicEngine engine) - { - decimal length = engine.EvaluationStack.Pop().ToNumber(); - decimal start = engine.EvaluationStack.Pop().ToNumber(); - string text = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Text.GetSubText(text: text, start: start, length: length); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetSubText", new Method( - name: "GetSubText", - description: LibrariesResources.Text_GetSubText, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_GetSubText_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Text_GetSubText_text) }, - { "start", new Parameter("start", LibrariesResources.Text_GetSubText_start) }, - { "length", new Parameter("length", LibrariesResources.Text_GetSubText_length) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.GetSubTextToEnd: - { - Task execute(SmallBasicEngine engine) - { - decimal start = engine.EvaluationStack.Pop().ToNumber(); - string text = engine.EvaluationStack.Pop().ToString(); - string returnValue = engine.Libraries.Text.GetSubTextToEnd(text: text, start: start); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("GetSubTextToEnd", new Method( - name: "GetSubTextToEnd", - description: LibrariesResources.Text_GetSubTextToEnd, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_GetSubTextToEnd_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Text_GetSubTextToEnd_text) }, - { "start", new Parameter("start", LibrariesResources.Text_GetSubTextToEnd_start) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.IsSubText: - { - Task execute(SmallBasicEngine engine) - { - string subText = engine.EvaluationStack.Pop().ToString(); - string text = engine.EvaluationStack.Pop().ToString(); - bool returnValue = engine.Libraries.Text.IsSubText(text: text, subText: subText); - engine.EvaluationStack.Push(new BooleanValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("IsSubText", new Method( - name: "IsSubText", - description: LibrariesResources.Text_IsSubText, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_IsSubText_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Text_IsSubText_text) }, - { "subText", new Parameter("subText", LibrariesResources.Text_IsSubText_subText) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Text.StartsWith: - { - Task execute(SmallBasicEngine engine) - { - string subText = engine.EvaluationStack.Pop().ToString(); - string text = engine.EvaluationStack.Pop().ToString(); - bool returnValue = engine.Libraries.Text.StartsWith(text: text, subText: subText); - engine.EvaluationStack.Push(new BooleanValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("StartsWith", new Method( - name: "StartsWith", - description: LibrariesResources.Text_StartsWith, - returnsValue: true, - returnValueDescription: LibrariesResources.Text_StartsWith_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "text", new Parameter("text", LibrariesResources.Text_StartsWith_text) }, - { "subText", new Parameter("subText", LibrariesResources.Text_StartsWith_subText) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Text", new Library("Text", LibrariesResources.Text, "text-height", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'TextWindow' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method TextWindow.Clear: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.TextWindow.Clear(); - return Task.CompletedTask; - } - - methods.Add("Clear", new Method( - name: "Clear", - description: LibrariesResources.TextWindow_Clear, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method TextWindow.Hide: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'TextWindow.Hide' is deprecated."); - } - - methods.Add("Hide", new Method( - name: "Hide", - description: LibrariesResources.TextWindow_Hide, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method TextWindow.Pause: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'TextWindow.Pause' is deprecated."); - } - - methods.Add("Pause", new Method( - name: "Pause", - description: LibrariesResources.TextWindow_Pause, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method TextWindow.PauseIfVisible: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'TextWindow.PauseIfVisible' is deprecated."); - } - - methods.Add("PauseIfVisible", new Method( - name: "PauseIfVisible", - description: LibrariesResources.TextWindow_PauseIfVisible, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method TextWindow.PauseWithoutMessage: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'TextWindow.PauseWithoutMessage' is deprecated."); - } - - methods.Add("PauseWithoutMessage", new Method( - name: "PauseWithoutMessage", - description: LibrariesResources.TextWindow_PauseWithoutMessage, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method TextWindow.Read: - { - Task execute(SmallBasicEngine engine) - { - string returnValue = engine.Libraries.TextWindow.Read(); - engine.EvaluationStack.Push(StringValue.Create(returnValue)); - return Task.CompletedTask; - } - - methods.Add("Read", new Method( - name: "Read", - description: LibrariesResources.TextWindow_Read, - returnsValue: true, - returnValueDescription: LibrariesResources.TextWindow_Read_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method TextWindow.ReadNumber: - { - Task execute(SmallBasicEngine engine) - { - decimal returnValue = engine.Libraries.TextWindow.ReadNumber(); - engine.EvaluationStack.Push(new NumberValue(returnValue)); - return Task.CompletedTask; - } - - methods.Add("ReadNumber", new Method( - name: "ReadNumber", - description: LibrariesResources.TextWindow_ReadNumber, - returnsValue: true, - returnValueDescription: LibrariesResources.TextWindow_ReadNumber_ReturnValue, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method TextWindow.Show: - { - Task execute(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library method 'TextWindow.Show' is deprecated."); - } - - methods.Add("Show", new Method( - name: "Show", - description: LibrariesResources.TextWindow_Show, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: true, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method TextWindow.Write: - { - Task execute(SmallBasicEngine engine) - { - string data = engine.EvaluationStack.Pop().ToString(); - return engine.Libraries.TextWindow.Write(data: data); - } - - methods.Add("Write", new Method( - name: "Write", - description: LibrariesResources.TextWindow_Write, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "data", new Parameter("data", LibrariesResources.TextWindow_Write_data) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method TextWindow.WriteLine: - { - Task execute(SmallBasicEngine engine) - { - string data = engine.EvaluationStack.Pop().ToString(); - return engine.Libraries.TextWindow.WriteLine(data: data); - } - - methods.Add("WriteLine", new Method( - name: "WriteLine", - description: LibrariesResources.TextWindow_WriteLine, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "data", new Parameter("data", LibrariesResources.TextWindow_WriteLine_data) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property TextWindow.BackgroundColor: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.TextWindow.Get_BackgroundColor(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.TextWindow.Set_BackgroundColor(value); - return Task.CompletedTask; - } - - properties.Add("BackgroundColor", new Property("BackgroundColor", LibrariesResources.TextWindow_BackgroundColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property TextWindow.CursorLeft: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'TextWindow.CursorLeft' is deprecated."); - } - - Task setter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'TextWindow.CursorLeft' is deprecated."); - } - - properties.Add("CursorLeft", new Property("CursorLeft", LibrariesResources.TextWindow_CursorLeft, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property TextWindow.CursorTop: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'TextWindow.CursorTop' is deprecated."); - } - - Task setter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'TextWindow.CursorTop' is deprecated."); - } - - properties.Add("CursorTop", new Property("CursorTop", LibrariesResources.TextWindow_CursorTop, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property TextWindow.ForegroundColor: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.TextWindow.Get_ForegroundColor(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.TextWindow.Set_ForegroundColor(value); - return Task.CompletedTask; - } - - properties.Add("ForegroundColor", new Property("ForegroundColor", LibrariesResources.TextWindow_ForegroundColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property TextWindow.Left: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'TextWindow.Left' is deprecated."); - } - - Task setter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'TextWindow.Left' is deprecated."); - } - - properties.Add("Left", new Property("Left", LibrariesResources.TextWindow_Left, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property TextWindow.Title: - { - Task getter(SmallBasicEngine engine) - { - string value = engine.Libraries.TextWindow.Get_Title(); - engine.EvaluationStack.Push(StringValue.Create(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - string value = engine.EvaluationStack.Pop().ToString(); - engine.Libraries.TextWindow.Set_Title(value); - return Task.CompletedTask; - } - - properties.Add("Title", new Property("Title", LibrariesResources.TextWindow_Title, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property TextWindow.Top: - { - Task getter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'TextWindow.Top' is deprecated."); - } - - Task setter(SmallBasicEngine engine) - { - throw new InvalidOperationException("Library property 'TextWindow.Top' is deprecated."); - } - - properties.Add("Top", new Property("Top", LibrariesResources.TextWindow_Top, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("TextWindow", new Library("TextWindow", LibrariesResources.TextWindow, "terminal", usesGraphicsWindow: false, usesTextWindow: true, methods, properties, events)); - } - - // Initialization code for library 'Timer' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Timer.Pause: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Timer.Pause(); - return Task.CompletedTask; - } - - methods.Add("Pause", new Method( - name: "Pause", - description: LibrariesResources.Timer_Pause, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Timer.Resume: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Timer.Resume(); - return Task.CompletedTask; - } - - methods.Add("Resume", new Method( - name: "Resume", - description: LibrariesResources.Timer_Resume, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property Timer.Interval: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Timer.Get_Interval(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - decimal value = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.Timer.Set_Interval(value); - return Task.CompletedTask; - } - - properties.Add("Interval", new Property("Interval", LibrariesResources.Timer_Interval, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "Tick", new Event("Tick", LibrariesResources.Timer_Tick) }, - }; - - types.Add("Timer", new Library("Timer", LibrariesResources.Timer, "stopwatch", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); - } - - // Initialization code for library 'Turtle' - { - var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for method Turtle.Hide: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Turtle.Hide(); - return Task.CompletedTask; - } - - methods.Add("Hide", new Method( - name: "Hide", - description: LibrariesResources.Turtle_Hide, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Turtle.Move: - { - Task execute(SmallBasicEngine engine) - { - decimal distance = engine.EvaluationStack.Pop().ToNumber(); - return engine.Libraries.Turtle.Move(distance: distance); - } - - methods.Add("Move", new Method( - name: "Move", - description: LibrariesResources.Turtle_Move, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "distance", new Parameter("distance", LibrariesResources.Turtle_Move_distance) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Turtle.MoveTo: - { - Task execute(SmallBasicEngine engine) - { - decimal y = engine.EvaluationStack.Pop().ToNumber(); - decimal x = engine.EvaluationStack.Pop().ToNumber(); - return engine.Libraries.Turtle.MoveTo(x: x, y: y); - } - - methods.Add("MoveTo", new Method( - name: "MoveTo", - description: LibrariesResources.Turtle_MoveTo, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "x", new Parameter("x", LibrariesResources.Turtle_MoveTo_x) }, - { "y", new Parameter("y", LibrariesResources.Turtle_MoveTo_y) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Turtle.PenDown: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Turtle.PenDown(); - return Task.CompletedTask; - } - - methods.Add("PenDown", new Method( - name: "PenDown", - description: LibrariesResources.Turtle_PenDown, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Turtle.PenUp: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Turtle.PenUp(); - return Task.CompletedTask; - } - - methods.Add("PenUp", new Method( - name: "PenUp", - description: LibrariesResources.Turtle_PenUp, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Turtle.Show: - { - Task execute(SmallBasicEngine engine) - { - engine.Libraries.Turtle.Show(); - return Task.CompletedTask; - } - - methods.Add("Show", new Method( - name: "Show", - description: LibrariesResources.Turtle_Show, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Turtle.Turn: - { - Task execute(SmallBasicEngine engine) - { - decimal angle = engine.EvaluationStack.Pop().ToNumber(); - return engine.Libraries.Turtle.Turn(angle: angle); - } - - methods.Add("Turn", new Method( - name: "Turn", - description: LibrariesResources.Turtle_Turn, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) - { - { "angle", new Parameter("angle", LibrariesResources.Turtle_Turn_angle) }, - }, - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Turtle.TurnLeft: - { - Task execute(SmallBasicEngine engine) - { - return engine.Libraries.Turtle.TurnLeft(); - } - - methods.Add("TurnLeft", new Method( - name: "TurnLeft", - description: LibrariesResources.Turtle_TurnLeft, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - // Initialization code for method Turtle.TurnRight: - { - Task execute(SmallBasicEngine engine) - { - return engine.Libraries.Turtle.TurnRight(); - } - - methods.Add("TurnRight", new Method( - name: "TurnRight", - description: LibrariesResources.Turtle_TurnRight, - returnsValue: false, - returnValueDescription: null, - parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), - isDeprecated: false, - needsDesktop: false, - execute: execute)); - } - - var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - // Initialization code for property Turtle.Angle: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Turtle.Get_Angle(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - decimal value = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.Turtle.Set_Angle(value); - return Task.CompletedTask; - } - - properties.Add("Angle", new Property("Angle", LibrariesResources.Turtle_Angle, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property Turtle.Speed: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Turtle.Get_Speed(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - decimal value = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.Turtle.Set_Speed(value); - return Task.CompletedTask; - } - - properties.Add("Speed", new Property("Speed", LibrariesResources.Turtle_Speed, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property Turtle.X: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Turtle.Get_X(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - decimal value = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.Turtle.Set_X(value); - return Task.CompletedTask; - } - - properties.Add("X", new Property("X", LibrariesResources.Turtle_X, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - // Initialization code for property Turtle.Y: - { - Task getter(SmallBasicEngine engine) - { - decimal value = engine.Libraries.Turtle.Get_Y(); - engine.EvaluationStack.Push(new NumberValue(value)); - return Task.CompletedTask; - } - - Task setter(SmallBasicEngine engine) - { - decimal value = engine.EvaluationStack.Pop().ToNumber(); - engine.Libraries.Turtle.Set_Y(value); - return Task.CompletedTask; - } - - properties.Add("Y", new Property("Y", LibrariesResources.Turtle_Y, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); - } - - var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); - - types.Add("Turtle", new Library("Turtle", LibrariesResources.Turtle, "pen-alt", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); - } - - Types = types; - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Compiler.Runtime +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using SmallBasic.Utilities.Resources; + + internal delegate Task DExecuteLibraryMember(SmallBasicEngine engine); + + public sealed class Library + { + internal Library( + string name, + string description, + string explorerIcon, + bool usesGraphicsWindow, + bool usesTextWindow, + IReadOnlyDictionary methods, + IReadOnlyDictionary properties, + IReadOnlyDictionary events) + { + this.Name = name; + this.Description = description; + this.ExplorerIcon = explorerIcon; + this.UsesGraphicsWindow = usesGraphicsWindow; + this.UsesTextWindow = usesTextWindow; + this.Methods = methods; + this.Properties = properties; + this.Events = events; + } + + public string Name { get; private set; } + + public string Description { get; private set; } + + public string ExplorerIcon { get; private set; } + + public bool UsesGraphicsWindow { get; private set; } + + public bool UsesTextWindow { get; private set; } + + public IReadOnlyDictionary Methods { get; private set; } + + public IReadOnlyDictionary Properties { get; private set; } + + public IReadOnlyDictionary Events { get; private set; } + } + + public sealed class Parameter + { + internal Parameter( + string name, + string description) + { + this.Name = name; + this.Description = description; + } + + public string Name { get; private set; } + + public string Description { get; private set; } + } + + public sealed class Method + { + internal Method( + string name, + string description, + bool returnsValue, + string returnValueDescription, + IReadOnlyDictionary parameters, + bool isDeprecated, + bool needsDesktop, + DExecuteLibraryMember execute) + { + this.Name = name; + this.Description = description; + this.ReturnsValue = returnsValue; + this.ReturnValueDescription = returnValueDescription; + this.Parameters = parameters; + this.IsDeprecated = isDeprecated; + this.NeedsDesktop = needsDesktop; + this.Execute = execute; + } + + public string Name { get; private set; } + + public string Description { get; private set; } + + public bool ReturnsValue { get; private set; } + + public string ReturnValueDescription { get; private set; } + + public IReadOnlyDictionary Parameters { get; private set; } + + internal bool IsDeprecated { get; private set; } + + internal bool NeedsDesktop { get; private set; } + + internal DExecuteLibraryMember Execute { get; private set; } + } + + public sealed class Property + { + internal Property( + string name, + string description, + bool isDeprecated, + bool needsDesktop, + DExecuteLibraryMember getter, + DExecuteLibraryMember setter) + { + this.Name = name; + this.Description = description; + this.IsDeprecated = isDeprecated; + this.NeedsDesktop = needsDesktop; + this.Getter = getter; + this.Setter = setter; + } + + public string Name { get; private set; } + + public string Description { get; private set; } + + internal bool IsDeprecated { get; private set; } + + internal bool NeedsDesktop { get; private set; } + + internal DExecuteLibraryMember Getter { get; private set; } + + internal DExecuteLibraryMember Setter { get; private set; } + } + + public sealed class Event + { + internal Event( + string name, + string description) + { + this.Name = name; + this.Description = description; + } + + public string Name { get; private set; } + + public string Description { get; private set; } + } + + public static class Libraries + { + public static readonly IReadOnlyDictionary Types; + + static Libraries() + { + var types = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for library 'Array' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Array.ContainsIndex: + { + Task execute(SmallBasicEngine engine) + { + string index = engine.EvaluationStack.Pop().ToString(); + ArrayValue array = engine.EvaluationStack.Pop().ToArray(); + bool returnValue = engine.Libraries.Array.ContainsIndex(array: array, index: index); + engine.EvaluationStack.Push(new BooleanValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("ContainsIndex", new Method( + name: "ContainsIndex", + description: LibrariesResources.Array_ContainsIndex, + returnsValue: true, + returnValueDescription: LibrariesResources.Array_ContainsIndex_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "array", new Parameter("array", LibrariesResources.Array_ContainsIndex_array) }, + { "index", new Parameter("index", LibrariesResources.Array_ContainsIndex_index) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Array.ContainsValue: + { + Task execute(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + ArrayValue array = engine.EvaluationStack.Pop().ToArray(); + bool returnValue = engine.Libraries.Array.ContainsValue(array: array, value: value); + engine.EvaluationStack.Push(new BooleanValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("ContainsValue", new Method( + name: "ContainsValue", + description: LibrariesResources.Array_ContainsValue, + returnsValue: true, + returnValueDescription: LibrariesResources.Array_ContainsValue_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "array", new Parameter("array", LibrariesResources.Array_ContainsValue_array) }, + { "value", new Parameter("value", LibrariesResources.Array_ContainsValue_value) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Array.GetAllIndices: + { + Task execute(SmallBasicEngine engine) + { + ArrayValue array = engine.EvaluationStack.Pop().ToArray(); + ArrayValue returnValue = engine.Libraries.Array.GetAllIndices(array: array); + engine.EvaluationStack.Push(returnValue); + return Task.CompletedTask; + } + + methods.Add("GetAllIndices", new Method( + name: "GetAllIndices", + description: LibrariesResources.Array_GetAllIndices, + returnsValue: true, + returnValueDescription: LibrariesResources.Array_GetAllIndices_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "array", new Parameter("array", LibrariesResources.Array_GetAllIndices_array) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Array.GetItemCount: + { + Task execute(SmallBasicEngine engine) + { + ArrayValue array = engine.EvaluationStack.Pop().ToArray(); + decimal returnValue = engine.Libraries.Array.GetItemCount(array: array); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetItemCount", new Method( + name: "GetItemCount", + description: LibrariesResources.Array_GetItemCount, + returnsValue: true, + returnValueDescription: LibrariesResources.Array_GetItemCount_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "array", new Parameter("array", LibrariesResources.Array_GetItemCount_array) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Array.GetValue: + { + Task execute(SmallBasicEngine engine) + { + string index = engine.EvaluationStack.Pop().ToString(); + string arrayName = engine.EvaluationStack.Pop().ToString(); + BaseValue returnValue = engine.Libraries.Array.GetValue(arrayName: arrayName, index: index); + engine.EvaluationStack.Push(returnValue); + return Task.CompletedTask; + } + + methods.Add("GetValue", new Method( + name: "GetValue", + description: LibrariesResources.Array_GetValue, + returnsValue: true, + returnValueDescription: LibrariesResources.Array_GetValue_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "arrayName", new Parameter("arrayName", LibrariesResources.Array_GetValue_arrayName) }, + { "index", new Parameter("index", LibrariesResources.Array_GetValue_index) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Array.IsArray: + { + Task execute(SmallBasicEngine engine) + { + BaseValue array = engine.EvaluationStack.Pop(); + bool returnValue = engine.Libraries.Array.IsArray(array: array); + engine.EvaluationStack.Push(new BooleanValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("IsArray", new Method( + name: "IsArray", + description: LibrariesResources.Array_IsArray, + returnsValue: true, + returnValueDescription: LibrariesResources.Array_IsArray_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "array", new Parameter("array", LibrariesResources.Array_IsArray_array) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Array.RemoveValue: + { + Task execute(SmallBasicEngine engine) + { + string index = engine.EvaluationStack.Pop().ToString(); + string arrayName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Array.RemoveValue(arrayName: arrayName, index: index); + return Task.CompletedTask; + } + + methods.Add("RemoveValue", new Method( + name: "RemoveValue", + description: LibrariesResources.Array_RemoveValue, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "arrayName", new Parameter("arrayName", LibrariesResources.Array_RemoveValue_arrayName) }, + { "index", new Parameter("index", LibrariesResources.Array_RemoveValue_index) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Array.SetValue: + { + Task execute(SmallBasicEngine engine) + { + BaseValue value = engine.EvaluationStack.Pop(); + string index = engine.EvaluationStack.Pop().ToString(); + string arrayName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Array.SetValue(arrayName: arrayName, index: index, value: value); + return Task.CompletedTask; + } + + methods.Add("SetValue", new Method( + name: "SetValue", + description: LibrariesResources.Array_SetValue, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "arrayName", new Parameter("arrayName", LibrariesResources.Array_SetValue_arrayName) }, + { "index", new Parameter("index", LibrariesResources.Array_SetValue_index) }, + { "value", new Parameter("value", LibrariesResources.Array_SetValue_value) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Array", new Library("Array", LibrariesResources.Array, "th-list", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Clock' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property Clock.Date: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.Clock.Get_Date(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + properties.Add("Date", new Property("Date", LibrariesResources.Clock_Date, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.Day: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Clock.Get_Day(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("Day", new Property("Day", LibrariesResources.Clock_Day, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.ElapsedMilliseconds: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Clock.Get_ElapsedMilliseconds(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("ElapsedMilliseconds", new Property("ElapsedMilliseconds", LibrariesResources.Clock_ElapsedMilliseconds, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.Hour: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Clock.Get_Hour(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("Hour", new Property("Hour", LibrariesResources.Clock_Hour, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.Millisecond: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Clock.Get_Millisecond(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("Millisecond", new Property("Millisecond", LibrariesResources.Clock_Millisecond, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.Minute: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Clock.Get_Minute(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("Minute", new Property("Minute", LibrariesResources.Clock_Minute, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.Month: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Clock.Get_Month(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("Month", new Property("Month", LibrariesResources.Clock_Month, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.Second: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Clock.Get_Second(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("Second", new Property("Second", LibrariesResources.Clock_Second, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.Time: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.Clock.Get_Time(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + properties.Add("Time", new Property("Time", LibrariesResources.Clock_Time, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.WeekDay: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.Clock.Get_WeekDay(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + properties.Add("WeekDay", new Property("WeekDay", LibrariesResources.Clock_WeekDay, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Clock.Year: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Clock.Get_Year(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("Year", new Property("Year", LibrariesResources.Clock_Year, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Clock", new Library("Clock", LibrariesResources.Clock, "clock", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Controls' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Controls.AddButton: + { + Task execute(SmallBasicEngine engine) + { + decimal top = engine.EvaluationStack.Pop().ToNumber(); + decimal left = engine.EvaluationStack.Pop().ToNumber(); + string caption = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Controls.AddButton(caption: caption, left: left, top: top); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("AddButton", new Method( + name: "AddButton", + description: LibrariesResources.Controls_AddButton, + returnsValue: true, + returnValueDescription: LibrariesResources.Controls_AddButton_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "caption", new Parameter("caption", LibrariesResources.Controls_AddButton_caption) }, + { "left", new Parameter("left", LibrariesResources.Controls_AddButton_left) }, + { "top", new Parameter("top", LibrariesResources.Controls_AddButton_top) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.AddMultiLineTextBox: + { + Task execute(SmallBasicEngine engine) + { + decimal top = engine.EvaluationStack.Pop().ToNumber(); + decimal left = engine.EvaluationStack.Pop().ToNumber(); + string returnValue = engine.Libraries.Controls.AddMultiLineTextBox(left: left, top: top); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("AddMultiLineTextBox", new Method( + name: "AddMultiLineTextBox", + description: LibrariesResources.Controls_AddMultiLineTextBox, + returnsValue: true, + returnValueDescription: LibrariesResources.Controls_AddMultiLineTextBox_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "left", new Parameter("left", LibrariesResources.Controls_AddMultiLineTextBox_left) }, + { "top", new Parameter("top", LibrariesResources.Controls_AddMultiLineTextBox_top) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.AddTextBox: + { + Task execute(SmallBasicEngine engine) + { + decimal top = engine.EvaluationStack.Pop().ToNumber(); + decimal left = engine.EvaluationStack.Pop().ToNumber(); + string returnValue = engine.Libraries.Controls.AddTextBox(left: left, top: top); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("AddTextBox", new Method( + name: "AddTextBox", + description: LibrariesResources.Controls_AddTextBox, + returnsValue: true, + returnValueDescription: LibrariesResources.Controls_AddTextBox_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "left", new Parameter("left", LibrariesResources.Controls_AddTextBox_left) }, + { "top", new Parameter("top", LibrariesResources.Controls_AddTextBox_top) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.GetButtonCaption: + { + Task execute(SmallBasicEngine engine) + { + string buttonName = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Controls.GetButtonCaption(buttonName: buttonName); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetButtonCaption", new Method( + name: "GetButtonCaption", + description: LibrariesResources.Controls_GetButtonCaption, + returnsValue: true, + returnValueDescription: LibrariesResources.Controls_GetButtonCaption_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "buttonName", new Parameter("buttonName", LibrariesResources.Controls_GetButtonCaption_buttonName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.GetTextBoxText: + { + Task execute(SmallBasicEngine engine) + { + string textBoxName = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Controls.GetTextBoxText(textBoxName: textBoxName); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetTextBoxText", new Method( + name: "GetTextBoxText", + description: LibrariesResources.Controls_GetTextBoxText, + returnsValue: true, + returnValueDescription: LibrariesResources.Controls_GetTextBoxText_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "textBoxName", new Parameter("textBoxName", LibrariesResources.Controls_GetTextBoxText_textBoxName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.HideControl: + { + Task execute(SmallBasicEngine engine) + { + string controlName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Controls.HideControl(controlName: controlName); + return Task.CompletedTask; + } + + methods.Add("HideControl", new Method( + name: "HideControl", + description: LibrariesResources.Controls_HideControl, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "controlName", new Parameter("controlName", LibrariesResources.Controls_HideControl_controlName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.Move: + { + Task execute(SmallBasicEngine engine) + { + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + string control = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Controls.Move(control: control, x: x, y: y); + return Task.CompletedTask; + } + + methods.Add("Move", new Method( + name: "Move", + description: LibrariesResources.Controls_Move, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "control", new Parameter("control", LibrariesResources.Controls_Move_control) }, + { "x", new Parameter("x", LibrariesResources.Controls_Move_x) }, + { "y", new Parameter("y", LibrariesResources.Controls_Move_y) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.Remove: + { + Task execute(SmallBasicEngine engine) + { + string controlName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Controls.Remove(controlName: controlName); + return Task.CompletedTask; + } + + methods.Add("Remove", new Method( + name: "Remove", + description: LibrariesResources.Controls_Remove, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "controlName", new Parameter("controlName", LibrariesResources.Controls_Remove_controlName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.SetButtonCaption: + { + Task execute(SmallBasicEngine engine) + { + string caption = engine.EvaluationStack.Pop().ToString(); + string buttonName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Controls.SetButtonCaption(buttonName: buttonName, caption: caption); + return Task.CompletedTask; + } + + methods.Add("SetButtonCaption", new Method( + name: "SetButtonCaption", + description: LibrariesResources.Controls_SetButtonCaption, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "buttonName", new Parameter("buttonName", LibrariesResources.Controls_SetButtonCaption_buttonName) }, + { "caption", new Parameter("caption", LibrariesResources.Controls_SetButtonCaption_caption) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.SetSize: + { + Task execute(SmallBasicEngine engine) + { + decimal height = engine.EvaluationStack.Pop().ToNumber(); + decimal width = engine.EvaluationStack.Pop().ToNumber(); + string control = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Controls.SetSize(control: control, width: width, height: height); + return Task.CompletedTask; + } + + methods.Add("SetSize", new Method( + name: "SetSize", + description: LibrariesResources.Controls_SetSize, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "control", new Parameter("control", LibrariesResources.Controls_SetSize_control) }, + { "width", new Parameter("width", LibrariesResources.Controls_SetSize_width) }, + { "height", new Parameter("height", LibrariesResources.Controls_SetSize_height) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.SetTextBoxText: + { + Task execute(SmallBasicEngine engine) + { + string text = engine.EvaluationStack.Pop().ToString(); + string textBoxName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Controls.SetTextBoxText(textBoxName: textBoxName, text: text); + return Task.CompletedTask; + } + + methods.Add("SetTextBoxText", new Method( + name: "SetTextBoxText", + description: LibrariesResources.Controls_SetTextBoxText, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "textBoxName", new Parameter("textBoxName", LibrariesResources.Controls_SetTextBoxText_textBoxName) }, + { "text", new Parameter("text", LibrariesResources.Controls_SetTextBoxText_text) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Controls.ShowControl: + { + Task execute(SmallBasicEngine engine) + { + string controlName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Controls.ShowControl(controlName: controlName); + return Task.CompletedTask; + } + + methods.Add("ShowControl", new Method( + name: "ShowControl", + description: LibrariesResources.Controls_ShowControl, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "controlName", new Parameter("controlName", LibrariesResources.Controls_ShowControl_controlName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property Controls.LastClickedButton: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.Controls.Get_LastClickedButton(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + properties.Add("LastClickedButton", new Property("LastClickedButton", LibrariesResources.Controls_LastClickedButton, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Controls.LastTypedTextBox: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.Controls.Get_LastTypedTextBox(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + properties.Add("LastTypedTextBox", new Property("LastTypedTextBox", LibrariesResources.Controls_LastTypedTextBox, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "ButtonClicked", new Event("ButtonClicked", LibrariesResources.Controls_ButtonClicked) }, + { "TextTyped", new Event("TextTyped", LibrariesResources.Controls_TextTyped) }, + }; + + types.Add("Controls", new Library("Controls", LibrariesResources.Controls, "sliders-h", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Desktop' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Desktop.SetWallPaper: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Desktop.SetWallPaper' is deprecated."); + } + + methods.Add("SetWallPaper", new Method( + name: "SetWallPaper", + description: LibrariesResources.Desktop_SetWallPaper, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "fileOrUrl", new Parameter("fileOrUrl", LibrariesResources.Desktop_SetWallPaper_fileOrUrl) }, + }, + isDeprecated: true, + needsDesktop: true, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property Desktop.Height: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'Desktop.Height' is deprecated."); + } + + properties.Add("Height", new Property("Height", LibrariesResources.Desktop_Height, isDeprecated: true, needsDesktop: true, getter: getter, setter: null)); + } + + // Initialization code for property Desktop.Width: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'Desktop.Width' is deprecated."); + } + + properties.Add("Width", new Property("Width", LibrariesResources.Desktop_Width, isDeprecated: true, needsDesktop: true, getter: getter, setter: null)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Desktop", new Library("Desktop", LibrariesResources.Desktop, "desktop", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Dictionary' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Dictionary.GetDefinition: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinition' is deprecated."); + } + + methods.Add("GetDefinition", new Method( + name: "GetDefinition", + description: LibrariesResources.Dictionary_GetDefinition, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinition_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinition_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionEnglishToEnglish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToEnglish' is deprecated."); + } + + methods.Add("GetDefinitionEnglishToEnglish", new Method( + name: "GetDefinitionEnglishToEnglish", + description: LibrariesResources.Dictionary_GetDefinitionEnglishToEnglish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToEnglish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToEnglish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionEnglishToFrench: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToFrench' is deprecated."); + } + + methods.Add("GetDefinitionEnglishToFrench", new Method( + name: "GetDefinitionEnglishToFrench", + description: LibrariesResources.Dictionary_GetDefinitionEnglishToFrench, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToFrench_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToFrench_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionEnglishToGerman: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToGerman' is deprecated."); + } + + methods.Add("GetDefinitionEnglishToGerman", new Method( + name: "GetDefinitionEnglishToGerman", + description: LibrariesResources.Dictionary_GetDefinitionEnglishToGerman, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToGerman_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToGerman_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionEnglishToItalian: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToItalian' is deprecated."); + } + + methods.Add("GetDefinitionEnglishToItalian", new Method( + name: "GetDefinitionEnglishToItalian", + description: LibrariesResources.Dictionary_GetDefinitionEnglishToItalian, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToItalian_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToItalian_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionEnglishToJapanese: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToJapanese' is deprecated."); + } + + methods.Add("GetDefinitionEnglishToJapanese", new Method( + name: "GetDefinitionEnglishToJapanese", + description: LibrariesResources.Dictionary_GetDefinitionEnglishToJapanese, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToJapanese_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToJapanese_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionEnglishToKorean: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToKorean' is deprecated."); + } + + methods.Add("GetDefinitionEnglishToKorean", new Method( + name: "GetDefinitionEnglishToKorean", + description: LibrariesResources.Dictionary_GetDefinitionEnglishToKorean, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToKorean_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToKorean_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionEnglishToSimplifiedChinese: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToSimplifiedChinese' is deprecated."); + } + + methods.Add("GetDefinitionEnglishToSimplifiedChinese", new Method( + name: "GetDefinitionEnglishToSimplifiedChinese", + description: LibrariesResources.Dictionary_GetDefinitionEnglishToSimplifiedChinese, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToSimplifiedChinese_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToSimplifiedChinese_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionEnglishToSpanish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToSpanish' is deprecated."); + } + + methods.Add("GetDefinitionEnglishToSpanish", new Method( + name: "GetDefinitionEnglishToSpanish", + description: LibrariesResources.Dictionary_GetDefinitionEnglishToSpanish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToSpanish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToSpanish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionEnglishToTraditionalChinese: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionEnglishToTraditionalChinese' is deprecated."); + } + + methods.Add("GetDefinitionEnglishToTraditionalChinese", new Method( + name: "GetDefinitionEnglishToTraditionalChinese", + description: LibrariesResources.Dictionary_GetDefinitionEnglishToTraditionalChinese, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionEnglishToTraditionalChinese_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionEnglishToTraditionalChinese_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionFrenchToEnglish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionFrenchToEnglish' is deprecated."); + } + + methods.Add("GetDefinitionFrenchToEnglish", new Method( + name: "GetDefinitionFrenchToEnglish", + description: LibrariesResources.Dictionary_GetDefinitionFrenchToEnglish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionFrenchToEnglish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionFrenchToEnglish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionGermanToEnglish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionGermanToEnglish' is deprecated."); + } + + methods.Add("GetDefinitionGermanToEnglish", new Method( + name: "GetDefinitionGermanToEnglish", + description: LibrariesResources.Dictionary_GetDefinitionGermanToEnglish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionGermanToEnglish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionGermanToEnglish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionItalianToEnglish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionItalianToEnglish' is deprecated."); + } + + methods.Add("GetDefinitionItalianToEnglish", new Method( + name: "GetDefinitionItalianToEnglish", + description: LibrariesResources.Dictionary_GetDefinitionItalianToEnglish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionItalianToEnglish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionItalianToEnglish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionJapaneseToEnglish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionJapaneseToEnglish' is deprecated."); + } + + methods.Add("GetDefinitionJapaneseToEnglish", new Method( + name: "GetDefinitionJapaneseToEnglish", + description: LibrariesResources.Dictionary_GetDefinitionJapaneseToEnglish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionJapaneseToEnglish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionJapaneseToEnglish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionKoreanToEnglish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionKoreanToEnglish' is deprecated."); + } + + methods.Add("GetDefinitionKoreanToEnglish", new Method( + name: "GetDefinitionKoreanToEnglish", + description: LibrariesResources.Dictionary_GetDefinitionKoreanToEnglish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionKoreanToEnglish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionKoreanToEnglish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionSimplifiedChineseToEnglish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionSimplifiedChineseToEnglish' is deprecated."); + } + + methods.Add("GetDefinitionSimplifiedChineseToEnglish", new Method( + name: "GetDefinitionSimplifiedChineseToEnglish", + description: LibrariesResources.Dictionary_GetDefinitionSimplifiedChineseToEnglish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionSimplifiedChineseToEnglish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionSimplifiedChineseToEnglish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionSpanishToEnglish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionSpanishToEnglish' is deprecated."); + } + + methods.Add("GetDefinitionSpanishToEnglish", new Method( + name: "GetDefinitionSpanishToEnglish", + description: LibrariesResources.Dictionary_GetDefinitionSpanishToEnglish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionSpanishToEnglish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionSpanishToEnglish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Dictionary.GetDefinitionTraditionalChineseToEnglish: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Dictionary.GetDefinitionTraditionalChineseToEnglish' is deprecated."); + } + + methods.Add("GetDefinitionTraditionalChineseToEnglish", new Method( + name: "GetDefinitionTraditionalChineseToEnglish", + description: LibrariesResources.Dictionary_GetDefinitionTraditionalChineseToEnglish, + returnsValue: true, + returnValueDescription: LibrariesResources.Dictionary_GetDefinitionTraditionalChineseToEnglish_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "word", new Parameter("word", LibrariesResources.Dictionary_GetDefinitionTraditionalChineseToEnglish_word) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Dictionary", new Library("Dictionary", LibrariesResources.Dictionary, "font", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'File' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method File.AppendContents: + { + async Task execute(SmallBasicEngine engine) + { + string contents = engine.EvaluationStack.Pop().ToString(); + string filePath = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.File.AppendContents(filePath: filePath, contents: contents).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("AppendContents", new Method( + name: "AppendContents", + description: LibrariesResources.File_AppendContents, + returnsValue: true, + returnValueDescription: LibrariesResources.File_AppendContents_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.File_AppendContents_filePath) }, + { "contents", new Parameter("contents", LibrariesResources.File_AppendContents_contents) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.CopyFile: + { + async Task execute(SmallBasicEngine engine) + { + string destinationFilePath = engine.EvaluationStack.Pop().ToString(); + string sourceFilePath = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.File.CopyFile(sourceFilePath: sourceFilePath, destinationFilePath: destinationFilePath).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("CopyFile", new Method( + name: "CopyFile", + description: LibrariesResources.File_CopyFile, + returnsValue: true, + returnValueDescription: LibrariesResources.File_CopyFile_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "sourceFilePath", new Parameter("sourceFilePath", LibrariesResources.File_CopyFile_sourceFilePath) }, + { "destinationFilePath", new Parameter("destinationFilePath", LibrariesResources.File_CopyFile_destinationFilePath) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.CreateDirectory: + { + async Task execute(SmallBasicEngine engine) + { + string directoryPath = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.File.CreateDirectory(directoryPath: directoryPath).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("CreateDirectory", new Method( + name: "CreateDirectory", + description: LibrariesResources.File_CreateDirectory, + returnsValue: true, + returnValueDescription: LibrariesResources.File_CreateDirectory_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "directoryPath", new Parameter("directoryPath", LibrariesResources.File_CreateDirectory_directoryPath) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.DeleteDirectory: + { + async Task execute(SmallBasicEngine engine) + { + string directoryPath = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.File.DeleteDirectory(directoryPath: directoryPath).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("DeleteDirectory", new Method( + name: "DeleteDirectory", + description: LibrariesResources.File_DeleteDirectory, + returnsValue: true, + returnValueDescription: LibrariesResources.File_DeleteDirectory_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "directoryPath", new Parameter("directoryPath", LibrariesResources.File_DeleteDirectory_directoryPath) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.DeleteFile: + { + async Task execute(SmallBasicEngine engine) + { + string filePath = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.File.DeleteFile(filePath: filePath).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("DeleteFile", new Method( + name: "DeleteFile", + description: LibrariesResources.File_DeleteFile, + returnsValue: true, + returnValueDescription: LibrariesResources.File_DeleteFile_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.File_DeleteFile_filePath) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.GetDirectories: + { + async Task execute(SmallBasicEngine engine) + { + string directoryPath = engine.EvaluationStack.Pop().ToString(); + BaseValue returnValue = await engine.Libraries.File.GetDirectories(directoryPath: directoryPath).ConfigureAwait(false); + engine.EvaluationStack.Push(returnValue); + } + + methods.Add("GetDirectories", new Method( + name: "GetDirectories", + description: LibrariesResources.File_GetDirectories, + returnsValue: true, + returnValueDescription: LibrariesResources.File_GetDirectories_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "directoryPath", new Parameter("directoryPath", LibrariesResources.File_GetDirectories_directoryPath) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.GetFiles: + { + async Task execute(SmallBasicEngine engine) + { + string directoryPath = engine.EvaluationStack.Pop().ToString(); + BaseValue returnValue = await engine.Libraries.File.GetFiles(directoryPath: directoryPath).ConfigureAwait(false); + engine.EvaluationStack.Push(returnValue); + } + + methods.Add("GetFiles", new Method( + name: "GetFiles", + description: LibrariesResources.File_GetFiles, + returnsValue: true, + returnValueDescription: LibrariesResources.File_GetFiles_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "directoryPath", new Parameter("directoryPath", LibrariesResources.File_GetFiles_directoryPath) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.GetSettingsFilePath: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'File.GetSettingsFilePath' is deprecated."); + } + + methods.Add("GetSettingsFilePath", new Method( + name: "GetSettingsFilePath", + description: LibrariesResources.File_GetSettingsFilePath, + returnsValue: true, + returnValueDescription: LibrariesResources.File_GetSettingsFilePath_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.GetTemporaryFilePath: + { + async Task execute(SmallBasicEngine engine) + { + BaseValue returnValue = await engine.Libraries.File.GetTemporaryFilePath().ConfigureAwait(false); + engine.EvaluationStack.Push(returnValue); + } + + methods.Add("GetTemporaryFilePath", new Method( + name: "GetTemporaryFilePath", + description: LibrariesResources.File_GetTemporaryFilePath, + returnsValue: true, + returnValueDescription: LibrariesResources.File_GetTemporaryFilePath_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.InsertLine: + { + async Task execute(SmallBasicEngine engine) + { + string contents = engine.EvaluationStack.Pop().ToString(); + decimal lineNumber = engine.EvaluationStack.Pop().ToNumber(); + string filePath = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.File.InsertLine(filePath: filePath, lineNumber: lineNumber, contents: contents).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("InsertLine", new Method( + name: "InsertLine", + description: LibrariesResources.File_InsertLine, + returnsValue: true, + returnValueDescription: LibrariesResources.File_InsertLine_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.File_InsertLine_filePath) }, + { "lineNumber", new Parameter("lineNumber", LibrariesResources.File_InsertLine_lineNumber) }, + { "contents", new Parameter("contents", LibrariesResources.File_InsertLine_contents) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.ReadContents: + { + async Task execute(SmallBasicEngine engine) + { + string filePath = engine.EvaluationStack.Pop().ToString(); + BaseValue returnValue = await engine.Libraries.File.ReadContents(filePath: filePath).ConfigureAwait(false); + engine.EvaluationStack.Push(returnValue); + } + + methods.Add("ReadContents", new Method( + name: "ReadContents", + description: LibrariesResources.File_ReadContents, + returnsValue: true, + returnValueDescription: LibrariesResources.File_ReadContents_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.File_ReadContents_filePath) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.ReadLine: + { + async Task execute(SmallBasicEngine engine) + { + decimal lineNumber = engine.EvaluationStack.Pop().ToNumber(); + string filePath = engine.EvaluationStack.Pop().ToString(); + BaseValue returnValue = await engine.Libraries.File.ReadLine(filePath: filePath, lineNumber: lineNumber).ConfigureAwait(false); + engine.EvaluationStack.Push(returnValue); + } + + methods.Add("ReadLine", new Method( + name: "ReadLine", + description: LibrariesResources.File_ReadLine, + returnsValue: true, + returnValueDescription: LibrariesResources.File_ReadLine_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.File_ReadLine_filePath) }, + { "lineNumber", new Parameter("lineNumber", LibrariesResources.File_ReadLine_lineNumber) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.WriteContents: + { + async Task execute(SmallBasicEngine engine) + { + string contents = engine.EvaluationStack.Pop().ToString(); + string filePath = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.File.WriteContents(filePath: filePath, contents: contents).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("WriteContents", new Method( + name: "WriteContents", + description: LibrariesResources.File_WriteContents, + returnsValue: true, + returnValueDescription: LibrariesResources.File_WriteContents_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.File_WriteContents_filePath) }, + { "contents", new Parameter("contents", LibrariesResources.File_WriteContents_contents) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method File.WriteLine: + { + async Task execute(SmallBasicEngine engine) + { + string contents = engine.EvaluationStack.Pop().ToString(); + decimal lineNumber = engine.EvaluationStack.Pop().ToNumber(); + string filePath = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.File.WriteLine(filePath: filePath, lineNumber: lineNumber, contents: contents).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("WriteLine", new Method( + name: "WriteLine", + description: LibrariesResources.File_WriteLine, + returnsValue: true, + returnValueDescription: LibrariesResources.File_WriteLine_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.File_WriteLine_filePath) }, + { "lineNumber", new Parameter("lineNumber", LibrariesResources.File_WriteLine_lineNumber) }, + { "contents", new Parameter("contents", LibrariesResources.File_WriteLine_contents) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property File.LastError: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.File.Get_LastError(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.File.Set_LastError(value); + return Task.CompletedTask; + } + + properties.Add("LastError", new Property("LastError", LibrariesResources.File_LastError, isDeprecated: false, needsDesktop: true, getter: getter, setter: setter)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("File", new Library("File", LibrariesResources.File, "file", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Flickr' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Flickr.GetPictureOfMoment: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Flickr.GetPictureOfMoment' is deprecated."); + } + + methods.Add("GetPictureOfMoment", new Method( + name: "GetPictureOfMoment", + description: LibrariesResources.Flickr_GetPictureOfMoment, + returnsValue: true, + returnValueDescription: LibrariesResources.Flickr_GetPictureOfMoment_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Flickr.GetRandomPicture: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Flickr.GetRandomPicture' is deprecated."); + } + + methods.Add("GetRandomPicture", new Method( + name: "GetRandomPicture", + description: LibrariesResources.Flickr_GetRandomPicture, + returnsValue: true, + returnValueDescription: LibrariesResources.Flickr_GetRandomPicture_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "tag", new Parameter("tag", LibrariesResources.Flickr_GetRandomPicture_tag) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Flickr", new Library("Flickr", LibrariesResources.Flickr, "camera", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'GraphicsWindow' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method GraphicsWindow.Clear: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.GraphicsWindow.Clear(); + return Task.CompletedTask; + } + + methods.Add("Clear", new Method( + name: "Clear", + description: LibrariesResources.GraphicsWindow_Clear, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.DrawBoundText: + { + Task execute(SmallBasicEngine engine) + { + string text = engine.EvaluationStack.Pop().ToString(); + decimal width = engine.EvaluationStack.Pop().ToNumber(); + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.DrawBoundText(x: x, y: y, width: width, text: text); + return Task.CompletedTask; + } + + methods.Add("DrawBoundText", new Method( + name: "DrawBoundText", + description: LibrariesResources.GraphicsWindow_DrawBoundText, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawBoundText_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawBoundText_y) }, + { "width", new Parameter("width", LibrariesResources.GraphicsWindow_DrawBoundText_width) }, + { "text", new Parameter("text", LibrariesResources.GraphicsWindow_DrawBoundText_text) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.DrawEllipse: + { + Task execute(SmallBasicEngine engine) + { + decimal height = engine.EvaluationStack.Pop().ToNumber(); + decimal width = engine.EvaluationStack.Pop().ToNumber(); + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.DrawEllipse(x: x, y: y, width: width, height: height); + return Task.CompletedTask; + } + + methods.Add("DrawEllipse", new Method( + name: "DrawEllipse", + description: LibrariesResources.GraphicsWindow_DrawEllipse, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawEllipse_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawEllipse_y) }, + { "width", new Parameter("width", LibrariesResources.GraphicsWindow_DrawEllipse_width) }, + { "height", new Parameter("height", LibrariesResources.GraphicsWindow_DrawEllipse_height) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.DrawImage: + { + Task execute(SmallBasicEngine engine) + { + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + string imageName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.GraphicsWindow.DrawImage(imageName: imageName, x: x, y: y); + return Task.CompletedTask; + } + + methods.Add("DrawImage", new Method( + name: "DrawImage", + description: LibrariesResources.GraphicsWindow_DrawImage, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "imageName", new Parameter("imageName", LibrariesResources.GraphicsWindow_DrawImage_imageName) }, + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawImage_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawImage_y) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.DrawLine: + { + Task execute(SmallBasicEngine engine) + { + decimal y2 = engine.EvaluationStack.Pop().ToNumber(); + decimal x2 = engine.EvaluationStack.Pop().ToNumber(); + decimal y1 = engine.EvaluationStack.Pop().ToNumber(); + decimal x1 = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.DrawLine(x1: x1, y1: y1, x2: x2, y2: y2); + return Task.CompletedTask; + } + + methods.Add("DrawLine", new Method( + name: "DrawLine", + description: LibrariesResources.GraphicsWindow_DrawLine, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x1", new Parameter("x1", LibrariesResources.GraphicsWindow_DrawLine_x1) }, + { "y1", new Parameter("y1", LibrariesResources.GraphicsWindow_DrawLine_y1) }, + { "x2", new Parameter("x2", LibrariesResources.GraphicsWindow_DrawLine_x2) }, + { "y2", new Parameter("y2", LibrariesResources.GraphicsWindow_DrawLine_y2) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.DrawRectangle: + { + Task execute(SmallBasicEngine engine) + { + decimal height = engine.EvaluationStack.Pop().ToNumber(); + decimal width = engine.EvaluationStack.Pop().ToNumber(); + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.DrawRectangle(x: x, y: y, width: width, height: height); + return Task.CompletedTask; + } + + methods.Add("DrawRectangle", new Method( + name: "DrawRectangle", + description: LibrariesResources.GraphicsWindow_DrawRectangle, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawRectangle_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawRectangle_y) }, + { "width", new Parameter("width", LibrariesResources.GraphicsWindow_DrawRectangle_width) }, + { "height", new Parameter("height", LibrariesResources.GraphicsWindow_DrawRectangle_height) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.DrawResizedImage: + { + Task execute(SmallBasicEngine engine) + { + decimal height = engine.EvaluationStack.Pop().ToNumber(); + decimal width = engine.EvaluationStack.Pop().ToNumber(); + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + string imageName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.GraphicsWindow.DrawResizedImage(imageName: imageName, x: x, y: y, width: width, height: height); + return Task.CompletedTask; + } + + methods.Add("DrawResizedImage", new Method( + name: "DrawResizedImage", + description: LibrariesResources.GraphicsWindow_DrawResizedImage, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "imageName", new Parameter("imageName", LibrariesResources.GraphicsWindow_DrawResizedImage_imageName) }, + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawResizedImage_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawResizedImage_y) }, + { "width", new Parameter("width", LibrariesResources.GraphicsWindow_DrawResizedImage_width) }, + { "height", new Parameter("height", LibrariesResources.GraphicsWindow_DrawResizedImage_height) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.DrawText: + { + Task execute(SmallBasicEngine engine) + { + string text = engine.EvaluationStack.Pop().ToString(); + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.DrawText(x: x, y: y, text: text); + return Task.CompletedTask; + } + + methods.Add("DrawText", new Method( + name: "DrawText", + description: LibrariesResources.GraphicsWindow_DrawText, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_DrawText_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_DrawText_y) }, + { "text", new Parameter("text", LibrariesResources.GraphicsWindow_DrawText_text) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.DrawTriangle: + { + Task execute(SmallBasicEngine engine) + { + decimal y3 = engine.EvaluationStack.Pop().ToNumber(); + decimal x3 = engine.EvaluationStack.Pop().ToNumber(); + decimal y2 = engine.EvaluationStack.Pop().ToNumber(); + decimal x2 = engine.EvaluationStack.Pop().ToNumber(); + decimal y1 = engine.EvaluationStack.Pop().ToNumber(); + decimal x1 = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.DrawTriangle(x1: x1, y1: y1, x2: x2, y2: y2, x3: x3, y3: y3); + return Task.CompletedTask; + } + + methods.Add("DrawTriangle", new Method( + name: "DrawTriangle", + description: LibrariesResources.GraphicsWindow_DrawTriangle, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x1", new Parameter("x1", LibrariesResources.GraphicsWindow_DrawTriangle_x1) }, + { "y1", new Parameter("y1", LibrariesResources.GraphicsWindow_DrawTriangle_y1) }, + { "x2", new Parameter("x2", LibrariesResources.GraphicsWindow_DrawTriangle_x2) }, + { "y2", new Parameter("y2", LibrariesResources.GraphicsWindow_DrawTriangle_y2) }, + { "x3", new Parameter("x3", LibrariesResources.GraphicsWindow_DrawTriangle_x3) }, + { "y3", new Parameter("y3", LibrariesResources.GraphicsWindow_DrawTriangle_y3) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.FillEllipse: + { + Task execute(SmallBasicEngine engine) + { + decimal height = engine.EvaluationStack.Pop().ToNumber(); + decimal width = engine.EvaluationStack.Pop().ToNumber(); + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.FillEllipse(x: x, y: y, width: width, height: height); + return Task.CompletedTask; + } + + methods.Add("FillEllipse", new Method( + name: "FillEllipse", + description: LibrariesResources.GraphicsWindow_FillEllipse, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_FillEllipse_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_FillEllipse_y) }, + { "width", new Parameter("width", LibrariesResources.GraphicsWindow_FillEllipse_width) }, + { "height", new Parameter("height", LibrariesResources.GraphicsWindow_FillEllipse_height) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.FillRectangle: + { + Task execute(SmallBasicEngine engine) + { + decimal height = engine.EvaluationStack.Pop().ToNumber(); + decimal width = engine.EvaluationStack.Pop().ToNumber(); + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.FillRectangle(x: x, y: y, width: width, height: height); + return Task.CompletedTask; + } + + methods.Add("FillRectangle", new Method( + name: "FillRectangle", + description: LibrariesResources.GraphicsWindow_FillRectangle, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_FillRectangle_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_FillRectangle_y) }, + { "width", new Parameter("width", LibrariesResources.GraphicsWindow_FillRectangle_width) }, + { "height", new Parameter("height", LibrariesResources.GraphicsWindow_FillRectangle_height) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.FillTriangle: + { + Task execute(SmallBasicEngine engine) + { + decimal y3 = engine.EvaluationStack.Pop().ToNumber(); + decimal x3 = engine.EvaluationStack.Pop().ToNumber(); + decimal y2 = engine.EvaluationStack.Pop().ToNumber(); + decimal x2 = engine.EvaluationStack.Pop().ToNumber(); + decimal y1 = engine.EvaluationStack.Pop().ToNumber(); + decimal x1 = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.FillTriangle(x1: x1, y1: y1, x2: x2, y2: y2, x3: x3, y3: y3); + return Task.CompletedTask; + } + + methods.Add("FillTriangle", new Method( + name: "FillTriangle", + description: LibrariesResources.GraphicsWindow_FillTriangle, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x1", new Parameter("x1", LibrariesResources.GraphicsWindow_FillTriangle_x1) }, + { "y1", new Parameter("y1", LibrariesResources.GraphicsWindow_FillTriangle_y1) }, + { "x2", new Parameter("x2", LibrariesResources.GraphicsWindow_FillTriangle_x2) }, + { "y2", new Parameter("y2", LibrariesResources.GraphicsWindow_FillTriangle_y2) }, + { "x3", new Parameter("x3", LibrariesResources.GraphicsWindow_FillTriangle_x3) }, + { "y3", new Parameter("y3", LibrariesResources.GraphicsWindow_FillTriangle_y3) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.GetColorFromRGB: + { + Task execute(SmallBasicEngine engine) + { + decimal blue = engine.EvaluationStack.Pop().ToNumber(); + decimal green = engine.EvaluationStack.Pop().ToNumber(); + decimal red = engine.EvaluationStack.Pop().ToNumber(); + string returnValue = engine.Libraries.GraphicsWindow.GetColorFromRGB(red: red, green: green, blue: blue); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetColorFromRGB", new Method( + name: "GetColorFromRGB", + description: LibrariesResources.GraphicsWindow_GetColorFromRGB, + returnsValue: true, + returnValueDescription: LibrariesResources.GraphicsWindow_GetColorFromRGB_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "red", new Parameter("red", LibrariesResources.GraphicsWindow_GetColorFromRGB_red) }, + { "green", new Parameter("green", LibrariesResources.GraphicsWindow_GetColorFromRGB_green) }, + { "blue", new Parameter("blue", LibrariesResources.GraphicsWindow_GetColorFromRGB_blue) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.GetPixel: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'GraphicsWindow.GetPixel' is deprecated."); + } + + methods.Add("GetPixel", new Method( + name: "GetPixel", + description: LibrariesResources.GraphicsWindow_GetPixel, + returnsValue: true, + returnValueDescription: LibrariesResources.GraphicsWindow_GetPixel_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_GetPixel_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_GetPixel_y) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.GetRandomColor: + { + Task execute(SmallBasicEngine engine) + { + string returnValue = engine.Libraries.GraphicsWindow.GetRandomColor(); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetRandomColor", new Method( + name: "GetRandomColor", + description: LibrariesResources.GraphicsWindow_GetRandomColor, + returnsValue: true, + returnValueDescription: LibrariesResources.GraphicsWindow_GetRandomColor_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.Hide: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.GraphicsWindow.Hide(); + return Task.CompletedTask; + } + + methods.Add("Hide", new Method( + name: "Hide", + description: LibrariesResources.GraphicsWindow_Hide, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.SetPixel: + { + Task execute(SmallBasicEngine engine) + { + string color = engine.EvaluationStack.Pop().ToString(); + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.SetPixel(x: x, y: y, color: color); + return Task.CompletedTask; + } + + methods.Add("SetPixel", new Method( + name: "SetPixel", + description: LibrariesResources.GraphicsWindow_SetPixel, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x", new Parameter("x", LibrariesResources.GraphicsWindow_SetPixel_x) }, + { "y", new Parameter("y", LibrariesResources.GraphicsWindow_SetPixel_y) }, + { "color", new Parameter("color", LibrariesResources.GraphicsWindow_SetPixel_color) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.Show: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.GraphicsWindow.Show(); + return Task.CompletedTask; + } + + methods.Add("Show", new Method( + name: "Show", + description: LibrariesResources.GraphicsWindow_Show, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method GraphicsWindow.ShowMessage: + { + Task execute(SmallBasicEngine engine) + { + string title = engine.EvaluationStack.Pop().ToString(); + string text = engine.EvaluationStack.Pop().ToString(); + return engine.Libraries.GraphicsWindow.ShowMessage(text: text, title: title); + } + + methods.Add("ShowMessage", new Method( + name: "ShowMessage", + description: LibrariesResources.GraphicsWindow_ShowMessage, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.GraphicsWindow_ShowMessage_text) }, + { "title", new Parameter("title", LibrariesResources.GraphicsWindow_ShowMessage_title) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property GraphicsWindow.BackgroundColor: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.GraphicsWindow.Get_BackgroundColor(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.GraphicsWindow.Set_BackgroundColor(value); + return Task.CompletedTask; + } + + properties.Add("BackgroundColor", new Property("BackgroundColor", LibrariesResources.GraphicsWindow_BackgroundColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.BrushColor: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.GraphicsWindow.Get_BrushColor(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.GraphicsWindow.Set_BrushColor(value); + return Task.CompletedTask; + } + + properties.Add("BrushColor", new Property("BrushColor", LibrariesResources.GraphicsWindow_BrushColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.CanResize: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'GraphicsWindow.CanResize' is deprecated."); + } + + Task setter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'GraphicsWindow.CanResize' is deprecated."); + } + + properties.Add("CanResize", new Property("CanResize", LibrariesResources.GraphicsWindow_CanResize, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.FontBold: + { + Task getter(SmallBasicEngine engine) + { + bool value = engine.Libraries.GraphicsWindow.Get_FontBold(); + engine.EvaluationStack.Push(new BooleanValue(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + bool value = engine.EvaluationStack.Pop().ToBoolean(); + engine.Libraries.GraphicsWindow.Set_FontBold(value); + return Task.CompletedTask; + } + + properties.Add("FontBold", new Property("FontBold", LibrariesResources.GraphicsWindow_FontBold, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.FontItalic: + { + Task getter(SmallBasicEngine engine) + { + bool value = engine.Libraries.GraphicsWindow.Get_FontItalic(); + engine.EvaluationStack.Push(new BooleanValue(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + bool value = engine.EvaluationStack.Pop().ToBoolean(); + engine.Libraries.GraphicsWindow.Set_FontItalic(value); + return Task.CompletedTask; + } + + properties.Add("FontItalic", new Property("FontItalic", LibrariesResources.GraphicsWindow_FontItalic, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.FontName: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.GraphicsWindow.Get_FontName(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.GraphicsWindow.Set_FontName(value); + return Task.CompletedTask; + } + + properties.Add("FontName", new Property("FontName", LibrariesResources.GraphicsWindow_FontName, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.FontSize: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.GraphicsWindow.Get_FontSize(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + decimal value = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.Set_FontSize(value); + return Task.CompletedTask; + } + + properties.Add("FontSize", new Property("FontSize", LibrariesResources.GraphicsWindow_FontSize, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.Height: + { + async Task getter(SmallBasicEngine engine) + { + decimal value = await engine.Libraries.GraphicsWindow.Get_Height().ConfigureAwait(false); + engine.EvaluationStack.Push(new NumberValue(value)); + } + + Task setter(SmallBasicEngine engine) + { + decimal value = engine.EvaluationStack.Pop().ToNumber(); + return engine.Libraries.GraphicsWindow.Set_Height(value); + } + + properties.Add("Height", new Property("Height", LibrariesResources.GraphicsWindow_Height, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.LastKey: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.GraphicsWindow.Get_LastKey(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + properties.Add("LastKey", new Property("LastKey", LibrariesResources.GraphicsWindow_LastKey, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property GraphicsWindow.LastText: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.GraphicsWindow.Get_LastText(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + properties.Add("LastText", new Property("LastText", LibrariesResources.GraphicsWindow_LastText, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property GraphicsWindow.Left: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'GraphicsWindow.Left' is deprecated."); + } + + Task setter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'GraphicsWindow.Left' is deprecated."); + } + + properties.Add("Left", new Property("Left", LibrariesResources.GraphicsWindow_Left, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.MouseX: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.GraphicsWindow.Get_MouseX(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("MouseX", new Property("MouseX", LibrariesResources.GraphicsWindow_MouseX, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property GraphicsWindow.MouseY: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.GraphicsWindow.Get_MouseY(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("MouseY", new Property("MouseY", LibrariesResources.GraphicsWindow_MouseY, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property GraphicsWindow.PenColor: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.GraphicsWindow.Get_PenColor(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.GraphicsWindow.Set_PenColor(value); + return Task.CompletedTask; + } + + properties.Add("PenColor", new Property("PenColor", LibrariesResources.GraphicsWindow_PenColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.PenWidth: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.GraphicsWindow.Get_PenWidth(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + decimal value = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.GraphicsWindow.Set_PenWidth(value); + return Task.CompletedTask; + } + + properties.Add("PenWidth", new Property("PenWidth", LibrariesResources.GraphicsWindow_PenWidth, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.Title: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.GraphicsWindow.Get_Title(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.GraphicsWindow.Set_Title(value); + return Task.CompletedTask; + } + + properties.Add("Title", new Property("Title", LibrariesResources.GraphicsWindow_Title, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.Top: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'GraphicsWindow.Top' is deprecated."); + } + + Task setter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'GraphicsWindow.Top' is deprecated."); + } + + properties.Add("Top", new Property("Top", LibrariesResources.GraphicsWindow_Top, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property GraphicsWindow.Width: + { + async Task getter(SmallBasicEngine engine) + { + decimal value = await engine.Libraries.GraphicsWindow.Get_Width().ConfigureAwait(false); + engine.EvaluationStack.Push(new NumberValue(value)); + } + + Task setter(SmallBasicEngine engine) + { + decimal value = engine.EvaluationStack.Pop().ToNumber(); + return engine.Libraries.GraphicsWindow.Set_Width(value); + } + + properties.Add("Width", new Property("Width", LibrariesResources.GraphicsWindow_Width, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "KeyDown", new Event("KeyDown", LibrariesResources.GraphicsWindow_KeyDown) }, + { "KeyUp", new Event("KeyUp", LibrariesResources.GraphicsWindow_KeyUp) }, + { "MouseDown", new Event("MouseDown", LibrariesResources.GraphicsWindow_MouseDown) }, + { "MouseMove", new Event("MouseMove", LibrariesResources.GraphicsWindow_MouseMove) }, + { "MouseUp", new Event("MouseUp", LibrariesResources.GraphicsWindow_MouseUp) }, + { "TextInput", new Event("TextInput", LibrariesResources.GraphicsWindow_TextInput) }, + }; + + types.Add("GraphicsWindow", new Library("GraphicsWindow", LibrariesResources.GraphicsWindow, "paint-brush", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'ImageList' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method ImageList.GetHeightOfImage: + { + Task execute(SmallBasicEngine engine) + { + string imageName = engine.EvaluationStack.Pop().ToString(); + decimal returnValue = engine.Libraries.ImageList.GetHeightOfImage(imageName: imageName); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetHeightOfImage", new Method( + name: "GetHeightOfImage", + description: LibrariesResources.ImageList_GetHeightOfImage, + returnsValue: true, + returnValueDescription: LibrariesResources.ImageList_GetHeightOfImage_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "imageName", new Parameter("imageName", LibrariesResources.ImageList_GetHeightOfImage_imageName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method ImageList.GetWidthOfImage: + { + Task execute(SmallBasicEngine engine) + { + string imageName = engine.EvaluationStack.Pop().ToString(); + decimal returnValue = engine.Libraries.ImageList.GetWidthOfImage(imageName: imageName); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetWidthOfImage", new Method( + name: "GetWidthOfImage", + description: LibrariesResources.ImageList_GetWidthOfImage, + returnsValue: true, + returnValueDescription: LibrariesResources.ImageList_GetWidthOfImage_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "imageName", new Parameter("imageName", LibrariesResources.ImageList_GetWidthOfImage_imageName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method ImageList.LoadImage: + { + async Task execute(SmallBasicEngine engine) + { + string fileNameOrUrl = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.ImageList.LoadImage(fileNameOrUrl: fileNameOrUrl).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("LoadImage", new Method( + name: "LoadImage", + description: LibrariesResources.ImageList_LoadImage, + returnsValue: true, + returnValueDescription: LibrariesResources.ImageList_LoadImage_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "fileNameOrUrl", new Parameter("fileNameOrUrl", LibrariesResources.ImageList_LoadImage_fileNameOrUrl) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("ImageList", new Library("ImageList", LibrariesResources.ImageList, "images", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Math' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Math.Abs: + { + Task execute(SmallBasicEngine engine) + { + decimal number = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Abs(number: number); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Abs", new Method( + name: "Abs", + description: LibrariesResources.Math_Abs, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Abs_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "number", new Parameter("number", LibrariesResources.Math_Abs_number) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.ArcCos: + { + Task execute(SmallBasicEngine engine) + { + decimal cosValue = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.ArcCos(cosValue: cosValue); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("ArcCos", new Method( + name: "ArcCos", + description: LibrariesResources.Math_ArcCos, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_ArcCos_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "cosValue", new Parameter("cosValue", LibrariesResources.Math_ArcCos_cosValue) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.ArcSin: + { + Task execute(SmallBasicEngine engine) + { + decimal sinValue = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.ArcSin(sinValue: sinValue); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("ArcSin", new Method( + name: "ArcSin", + description: LibrariesResources.Math_ArcSin, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_ArcSin_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "sinValue", new Parameter("sinValue", LibrariesResources.Math_ArcSin_sinValue) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.ArcTan: + { + Task execute(SmallBasicEngine engine) + { + decimal tanValue = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.ArcTan(tanValue: tanValue); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("ArcTan", new Method( + name: "ArcTan", + description: LibrariesResources.Math_ArcTan, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_ArcTan_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "tanValue", new Parameter("tanValue", LibrariesResources.Math_ArcTan_tanValue) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Ceiling: + { + Task execute(SmallBasicEngine engine) + { + decimal number = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Ceiling(number: number); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Ceiling", new Method( + name: "Ceiling", + description: LibrariesResources.Math_Ceiling, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Ceiling_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "number", new Parameter("number", LibrariesResources.Math_Ceiling_number) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Cos: + { + Task execute(SmallBasicEngine engine) + { + decimal angle = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Cos(angle: angle); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Cos", new Method( + name: "Cos", + description: LibrariesResources.Math_Cos, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Cos_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "angle", new Parameter("angle", LibrariesResources.Math_Cos_angle) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Floor: + { + Task execute(SmallBasicEngine engine) + { + decimal number = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Floor(number: number); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Floor", new Method( + name: "Floor", + description: LibrariesResources.Math_Floor, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Floor_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "number", new Parameter("number", LibrariesResources.Math_Floor_number) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.GetDegrees: + { + Task execute(SmallBasicEngine engine) + { + decimal angle = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.GetDegrees(angle: angle); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetDegrees", new Method( + name: "GetDegrees", + description: LibrariesResources.Math_GetDegrees, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_GetDegrees_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "angle", new Parameter("angle", LibrariesResources.Math_GetDegrees_angle) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.GetRadians: + { + Task execute(SmallBasicEngine engine) + { + decimal angle = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.GetRadians(angle: angle); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetRadians", new Method( + name: "GetRadians", + description: LibrariesResources.Math_GetRadians, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_GetRadians_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "angle", new Parameter("angle", LibrariesResources.Math_GetRadians_angle) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.GetRandomNumber: + { + Task execute(SmallBasicEngine engine) + { + decimal maxNumber = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.GetRandomNumber(maxNumber: maxNumber); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetRandomNumber", new Method( + name: "GetRandomNumber", + description: LibrariesResources.Math_GetRandomNumber, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_GetRandomNumber_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "maxNumber", new Parameter("maxNumber", LibrariesResources.Math_GetRandomNumber_maxNumber) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Log: + { + Task execute(SmallBasicEngine engine) + { + decimal number = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Log(number: number); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Log", new Method( + name: "Log", + description: LibrariesResources.Math_Log, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Log_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "number", new Parameter("number", LibrariesResources.Math_Log_number) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Max: + { + Task execute(SmallBasicEngine engine) + { + decimal number2 = engine.EvaluationStack.Pop().ToNumber(); + decimal number1 = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Max(number1: number1, number2: number2); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Max", new Method( + name: "Max", + description: LibrariesResources.Math_Max, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Max_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "number1", new Parameter("number1", LibrariesResources.Math_Max_number1) }, + { "number2", new Parameter("number2", LibrariesResources.Math_Max_number2) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Min: + { + Task execute(SmallBasicEngine engine) + { + decimal number2 = engine.EvaluationStack.Pop().ToNumber(); + decimal number1 = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Min(number1: number1, number2: number2); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Min", new Method( + name: "Min", + description: LibrariesResources.Math_Min, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Min_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "number1", new Parameter("number1", LibrariesResources.Math_Min_number1) }, + { "number2", new Parameter("number2", LibrariesResources.Math_Min_number2) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.NaturalLog: + { + Task execute(SmallBasicEngine engine) + { + decimal number = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.NaturalLog(number: number); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("NaturalLog", new Method( + name: "NaturalLog", + description: LibrariesResources.Math_NaturalLog, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_NaturalLog_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "number", new Parameter("number", LibrariesResources.Math_NaturalLog_number) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Power: + { + Task execute(SmallBasicEngine engine) + { + decimal exponent = engine.EvaluationStack.Pop().ToNumber(); + decimal baseNumber = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Power(baseNumber: baseNumber, exponent: exponent); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Power", new Method( + name: "Power", + description: LibrariesResources.Math_Power, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Power_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "baseNumber", new Parameter("baseNumber", LibrariesResources.Math_Power_baseNumber) }, + { "exponent", new Parameter("exponent", LibrariesResources.Math_Power_exponent) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Remainder: + { + Task execute(SmallBasicEngine engine) + { + decimal divisor = engine.EvaluationStack.Pop().ToNumber(); + decimal dividend = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Remainder(dividend: dividend, divisor: divisor); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Remainder", new Method( + name: "Remainder", + description: LibrariesResources.Math_Remainder, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Remainder_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "dividend", new Parameter("dividend", LibrariesResources.Math_Remainder_dividend) }, + { "divisor", new Parameter("divisor", LibrariesResources.Math_Remainder_divisor) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Round: + { + Task execute(SmallBasicEngine engine) + { + decimal number = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Round(number: number); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Round", new Method( + name: "Round", + description: LibrariesResources.Math_Round, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Round_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "number", new Parameter("number", LibrariesResources.Math_Round_number) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Sin: + { + Task execute(SmallBasicEngine engine) + { + decimal angle = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Sin(angle: angle); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Sin", new Method( + name: "Sin", + description: LibrariesResources.Math_Sin, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Sin_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "angle", new Parameter("angle", LibrariesResources.Math_Sin_angle) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.SquareRoot: + { + Task execute(SmallBasicEngine engine) + { + decimal number = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.SquareRoot(number: number); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("SquareRoot", new Method( + name: "SquareRoot", + description: LibrariesResources.Math_SquareRoot, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_SquareRoot_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "number", new Parameter("number", LibrariesResources.Math_SquareRoot_number) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Math.Tan: + { + Task execute(SmallBasicEngine engine) + { + decimal angle = engine.EvaluationStack.Pop().ToNumber(); + decimal returnValue = engine.Libraries.Math.Tan(angle: angle); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Tan", new Method( + name: "Tan", + description: LibrariesResources.Math_Tan, + returnsValue: true, + returnValueDescription: LibrariesResources.Math_Tan_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "angle", new Parameter("angle", LibrariesResources.Math_Tan_angle) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property Math.Pi: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Math.Get_Pi(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("Pi", new Property("Pi", LibrariesResources.Math_Pi, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Math", new Library("Math", LibrariesResources.Math, "calculator", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Mouse' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Mouse.HideCursor: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Mouse.HideCursor(); + return Task.CompletedTask; + } + + methods.Add("HideCursor", new Method( + name: "HideCursor", + description: LibrariesResources.Mouse_HideCursor, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Mouse.ShowCursor: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Mouse.ShowCursor(); + return Task.CompletedTask; + } + + methods.Add("ShowCursor", new Method( + name: "ShowCursor", + description: LibrariesResources.Mouse_ShowCursor, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property Mouse.IsLeftButtonDown: + { + Task getter(SmallBasicEngine engine) + { + bool value = engine.Libraries.Mouse.Get_IsLeftButtonDown(); + engine.EvaluationStack.Push(new BooleanValue(value)); + return Task.CompletedTask; + } + + properties.Add("IsLeftButtonDown", new Property("IsLeftButtonDown", LibrariesResources.Mouse_IsLeftButtonDown, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Mouse.IsRightButtonDown: + { + Task getter(SmallBasicEngine engine) + { + bool value = engine.Libraries.Mouse.Get_IsRightButtonDown(); + engine.EvaluationStack.Push(new BooleanValue(value)); + return Task.CompletedTask; + } + + properties.Add("IsRightButtonDown", new Property("IsRightButtonDown", LibrariesResources.Mouse_IsRightButtonDown, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Mouse.MouseX: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Mouse.Get_MouseX(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("MouseX", new Property("MouseX", LibrariesResources.Mouse_MouseX, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Mouse.MouseY: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Mouse.Get_MouseY(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + properties.Add("MouseY", new Property("MouseY", LibrariesResources.Mouse_MouseY, isDeprecated: false, needsDesktop: false, getter: getter, setter: null)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Mouse", new Library("Mouse", LibrariesResources.Mouse, "mouse-pointer", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Network' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Network.DownloadFile: + { + async Task execute(SmallBasicEngine engine) + { + string url = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.Network.DownloadFile(url: url).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("DownloadFile", new Method( + name: "DownloadFile", + description: LibrariesResources.Network_DownloadFile, + returnsValue: true, + returnValueDescription: LibrariesResources.Network_DownloadFile_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "url", new Parameter("url", LibrariesResources.Network_DownloadFile_url) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + // Initialization code for method Network.GetWebPageContents: + { + async Task execute(SmallBasicEngine engine) + { + string url = engine.EvaluationStack.Pop().ToString(); + string returnValue = await engine.Libraries.Network.GetWebPageContents(url: url).ConfigureAwait(false); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + } + + methods.Add("GetWebPageContents", new Method( + name: "GetWebPageContents", + description: LibrariesResources.Network_GetWebPageContents, + returnsValue: true, + returnValueDescription: LibrariesResources.Network_GetWebPageContents_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "url", new Parameter("url", LibrariesResources.Network_GetWebPageContents_url) }, + }, + isDeprecated: false, + needsDesktop: true, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Network", new Library("Network", LibrariesResources.Network, "network-wired", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Program' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Program.Delay: + { + Task execute(SmallBasicEngine engine) + { + decimal milliSeconds = engine.EvaluationStack.Pop().ToNumber(); + return engine.Libraries.Program.Delay(milliSeconds: milliSeconds); + } + + methods.Add("Delay", new Method( + name: "Delay", + description: LibrariesResources.Program_Delay, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "milliSeconds", new Parameter("milliSeconds", LibrariesResources.Program_Delay_milliSeconds) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Program.End: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Program.End(); + return Task.CompletedTask; + } + + methods.Add("End", new Method( + name: "End", + description: LibrariesResources.Program_End, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Program.GetArgument: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Program.GetArgument' is deprecated."); + } + + methods.Add("GetArgument", new Method( + name: "GetArgument", + description: LibrariesResources.Program_GetArgument, + returnsValue: true, + returnValueDescription: LibrariesResources.Program_GetArgument_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "index", new Parameter("index", LibrariesResources.Program_GetArgument_index) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Program.Pause: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Program.Pause(); + return Task.CompletedTask; + } + + methods.Add("Pause", new Method( + name: "Pause", + description: LibrariesResources.Program_Pause, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property Program.ArgumentCount: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'Program.ArgumentCount' is deprecated."); + } + + properties.Add("ArgumentCount", new Property("ArgumentCount", LibrariesResources.Program_ArgumentCount, isDeprecated: true, needsDesktop: false, getter: getter, setter: null)); + } + + // Initialization code for property Program.Directory: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'Program.Directory' is deprecated."); + } + + properties.Add("Directory", new Property("Directory", LibrariesResources.Program_Directory, isDeprecated: true, needsDesktop: false, getter: getter, setter: null)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Program", new Library("Program", LibrariesResources.Program, "laptop-code", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Shapes' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Shapes.AddEllipse: + { + Task execute(SmallBasicEngine engine) + { + decimal height = engine.EvaluationStack.Pop().ToNumber(); + decimal width = engine.EvaluationStack.Pop().ToNumber(); + string returnValue = engine.Libraries.Shapes.AddEllipse(width: width, height: height); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("AddEllipse", new Method( + name: "AddEllipse", + description: LibrariesResources.Shapes_AddEllipse, + returnsValue: true, + returnValueDescription: LibrariesResources.Shapes_AddEllipse_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "width", new Parameter("width", LibrariesResources.Shapes_AddEllipse_width) }, + { "height", new Parameter("height", LibrariesResources.Shapes_AddEllipse_height) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.AddImage: + { + Task execute(SmallBasicEngine engine) + { + string imageName = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Shapes.AddImage(imageName: imageName); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("AddImage", new Method( + name: "AddImage", + description: LibrariesResources.Shapes_AddImage, + returnsValue: true, + returnValueDescription: LibrariesResources.Shapes_AddImage_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "imageName", new Parameter("imageName", LibrariesResources.Shapes_AddImage_imageName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.AddLine: + { + Task execute(SmallBasicEngine engine) + { + decimal y2 = engine.EvaluationStack.Pop().ToNumber(); + decimal x2 = engine.EvaluationStack.Pop().ToNumber(); + decimal y1 = engine.EvaluationStack.Pop().ToNumber(); + decimal x1 = engine.EvaluationStack.Pop().ToNumber(); + string returnValue = engine.Libraries.Shapes.AddLine(x1: x1, y1: y1, x2: x2, y2: y2); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("AddLine", new Method( + name: "AddLine", + description: LibrariesResources.Shapes_AddLine, + returnsValue: true, + returnValueDescription: LibrariesResources.Shapes_AddLine_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x1", new Parameter("x1", LibrariesResources.Shapes_AddLine_x1) }, + { "y1", new Parameter("y1", LibrariesResources.Shapes_AddLine_y1) }, + { "x2", new Parameter("x2", LibrariesResources.Shapes_AddLine_x2) }, + { "y2", new Parameter("y2", LibrariesResources.Shapes_AddLine_y2) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.AddRectangle: + { + Task execute(SmallBasicEngine engine) + { + decimal height = engine.EvaluationStack.Pop().ToNumber(); + decimal width = engine.EvaluationStack.Pop().ToNumber(); + string returnValue = engine.Libraries.Shapes.AddRectangle(width: width, height: height); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("AddRectangle", new Method( + name: "AddRectangle", + description: LibrariesResources.Shapes_AddRectangle, + returnsValue: true, + returnValueDescription: LibrariesResources.Shapes_AddRectangle_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "width", new Parameter("width", LibrariesResources.Shapes_AddRectangle_width) }, + { "height", new Parameter("height", LibrariesResources.Shapes_AddRectangle_height) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.AddText: + { + Task execute(SmallBasicEngine engine) + { + string text = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Shapes.AddText(text: text); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("AddText", new Method( + name: "AddText", + description: LibrariesResources.Shapes_AddText, + returnsValue: true, + returnValueDescription: LibrariesResources.Shapes_AddText_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Shapes_AddText_text) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.AddTriangle: + { + Task execute(SmallBasicEngine engine) + { + decimal y3 = engine.EvaluationStack.Pop().ToNumber(); + decimal x3 = engine.EvaluationStack.Pop().ToNumber(); + decimal y2 = engine.EvaluationStack.Pop().ToNumber(); + decimal x2 = engine.EvaluationStack.Pop().ToNumber(); + decimal y1 = engine.EvaluationStack.Pop().ToNumber(); + decimal x1 = engine.EvaluationStack.Pop().ToNumber(); + string returnValue = engine.Libraries.Shapes.AddTriangle(x1: x1, y1: y1, x2: x2, y2: y2, x3: x3, y3: y3); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("AddTriangle", new Method( + name: "AddTriangle", + description: LibrariesResources.Shapes_AddTriangle, + returnsValue: true, + returnValueDescription: LibrariesResources.Shapes_AddTriangle_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x1", new Parameter("x1", LibrariesResources.Shapes_AddTriangle_x1) }, + { "y1", new Parameter("y1", LibrariesResources.Shapes_AddTriangle_y1) }, + { "x2", new Parameter("x2", LibrariesResources.Shapes_AddTriangle_x2) }, + { "y2", new Parameter("y2", LibrariesResources.Shapes_AddTriangle_y2) }, + { "x3", new Parameter("x3", LibrariesResources.Shapes_AddTriangle_x3) }, + { "y3", new Parameter("y3", LibrariesResources.Shapes_AddTriangle_y3) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.Animate: + { + Task execute(SmallBasicEngine engine) + { + decimal duration = engine.EvaluationStack.Pop().ToNumber(); + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + string shapeName = engine.EvaluationStack.Pop().ToString(); + return engine.Libraries.Shapes.Animate(shapeName: shapeName, x: x, y: y, duration: duration); + } + + methods.Add("Animate", new Method( + name: "Animate", + description: LibrariesResources.Shapes_Animate, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Animate_shapeName) }, + { "x", new Parameter("x", LibrariesResources.Shapes_Animate_x) }, + { "y", new Parameter("y", LibrariesResources.Shapes_Animate_y) }, + { "duration", new Parameter("duration", LibrariesResources.Shapes_Animate_duration) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.GetLeft: + { + Task execute(SmallBasicEngine engine) + { + string shapeName = engine.EvaluationStack.Pop().ToString(); + decimal returnValue = engine.Libraries.Shapes.GetLeft(shapeName: shapeName); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetLeft", new Method( + name: "GetLeft", + description: LibrariesResources.Shapes_GetLeft, + returnsValue: true, + returnValueDescription: LibrariesResources.Shapes_GetLeft_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_GetLeft_shapeName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.GetOpacity: + { + Task execute(SmallBasicEngine engine) + { + string shapeName = engine.EvaluationStack.Pop().ToString(); + decimal returnValue = engine.Libraries.Shapes.GetOpacity(shapeName: shapeName); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetOpacity", new Method( + name: "GetOpacity", + description: LibrariesResources.Shapes_GetOpacity, + returnsValue: true, + returnValueDescription: LibrariesResources.Shapes_GetOpacity_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_GetOpacity_shapeName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.GetTop: + { + Task execute(SmallBasicEngine engine) + { + string shapeName = engine.EvaluationStack.Pop().ToString(); + decimal returnValue = engine.Libraries.Shapes.GetTop(shapeName: shapeName); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetTop", new Method( + name: "GetTop", + description: LibrariesResources.Shapes_GetTop, + returnsValue: true, + returnValueDescription: LibrariesResources.Shapes_GetTop_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_GetTop_shapeName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.HideShape: + { + Task execute(SmallBasicEngine engine) + { + string shapeName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Shapes.HideShape(shapeName: shapeName); + return Task.CompletedTask; + } + + methods.Add("HideShape", new Method( + name: "HideShape", + description: LibrariesResources.Shapes_HideShape, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_HideShape_shapeName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.Move: + { + Task execute(SmallBasicEngine engine) + { + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + string shapeName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Shapes.Move(shapeName: shapeName, x: x, y: y); + return Task.CompletedTask; + } + + methods.Add("Move", new Method( + name: "Move", + description: LibrariesResources.Shapes_Move, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Move_shapeName) }, + { "x", new Parameter("x", LibrariesResources.Shapes_Move_x) }, + { "y", new Parameter("y", LibrariesResources.Shapes_Move_y) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.Remove: + { + Task execute(SmallBasicEngine engine) + { + string shapeName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Shapes.Remove(shapeName: shapeName); + return Task.CompletedTask; + } + + methods.Add("Remove", new Method( + name: "Remove", + description: LibrariesResources.Shapes_Remove, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Remove_shapeName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.Rotate: + { + Task execute(SmallBasicEngine engine) + { + decimal angle = engine.EvaluationStack.Pop().ToNumber(); + string shapeName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Shapes.Rotate(shapeName: shapeName, angle: angle); + return Task.CompletedTask; + } + + methods.Add("Rotate", new Method( + name: "Rotate", + description: LibrariesResources.Shapes_Rotate, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Rotate_shapeName) }, + { "angle", new Parameter("angle", LibrariesResources.Shapes_Rotate_angle) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.SetOpacity: + { + Task execute(SmallBasicEngine engine) + { + decimal level = engine.EvaluationStack.Pop().ToNumber(); + string shapeName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Shapes.SetOpacity(shapeName: shapeName, level: level); + return Task.CompletedTask; + } + + methods.Add("SetOpacity", new Method( + name: "SetOpacity", + description: LibrariesResources.Shapes_SetOpacity, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_SetOpacity_shapeName) }, + { "level", new Parameter("level", LibrariesResources.Shapes_SetOpacity_level) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.SetText: + { + Task execute(SmallBasicEngine engine) + { + string text = engine.EvaluationStack.Pop().ToString(); + string shapeName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Shapes.SetText(shapeName: shapeName, text: text); + return Task.CompletedTask; + } + + methods.Add("SetText", new Method( + name: "SetText", + description: LibrariesResources.Shapes_SetText, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_SetText_shapeName) }, + { "text", new Parameter("text", LibrariesResources.Shapes_SetText_text) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.ShowShape: + { + Task execute(SmallBasicEngine engine) + { + string shapeName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Shapes.ShowShape(shapeName: shapeName); + return Task.CompletedTask; + } + + methods.Add("ShowShape", new Method( + name: "ShowShape", + description: LibrariesResources.Shapes_ShowShape, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_ShowShape_shapeName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Shapes.Zoom: + { + Task execute(SmallBasicEngine engine) + { + decimal scaleY = engine.EvaluationStack.Pop().ToNumber(); + decimal scaleX = engine.EvaluationStack.Pop().ToNumber(); + string shapeName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Shapes.Zoom(shapeName: shapeName, scaleX: scaleX, scaleY: scaleY); + return Task.CompletedTask; + } + + methods.Add("Zoom", new Method( + name: "Zoom", + description: LibrariesResources.Shapes_Zoom, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "shapeName", new Parameter("shapeName", LibrariesResources.Shapes_Zoom_shapeName) }, + { "scaleX", new Parameter("scaleX", LibrariesResources.Shapes_Zoom_scaleX) }, + { "scaleY", new Parameter("scaleY", LibrariesResources.Shapes_Zoom_scaleY) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Shapes", new Library("Shapes", LibrariesResources.Shapes, "shapes", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Sound' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Sound.Pause: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.Pause' is deprecated."); + } + + methods.Add("Pause", new Method( + name: "Pause", + description: LibrariesResources.Sound_Pause, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.Sound_Pause_filePath) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.Play: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.Play' is deprecated."); + } + + methods.Add("Play", new Method( + name: "Play", + description: LibrariesResources.Sound_Play, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.Sound_Play_filePath) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayAndWait: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayAndWait' is deprecated."); + } + + methods.Add("PlayAndWait", new Method( + name: "PlayAndWait", + description: LibrariesResources.Sound_PlayAndWait, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.Sound_PlayAndWait_filePath) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayBellRing: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayBellRing' is deprecated."); + } + + methods.Add("PlayBellRing", new Method( + name: "PlayBellRing", + description: LibrariesResources.Sound_PlayBellRing, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayBellRingAndWait: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayBellRingAndWait' is deprecated."); + } + + methods.Add("PlayBellRingAndWait", new Method( + name: "PlayBellRingAndWait", + description: LibrariesResources.Sound_PlayBellRingAndWait, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayChime: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayChime' is deprecated."); + } + + methods.Add("PlayChime", new Method( + name: "PlayChime", + description: LibrariesResources.Sound_PlayChime, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayChimeAndWait: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayChimeAndWait' is deprecated."); + } + + methods.Add("PlayChimeAndWait", new Method( + name: "PlayChimeAndWait", + description: LibrariesResources.Sound_PlayChimeAndWait, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayChimes: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayChimes' is deprecated."); + } + + methods.Add("PlayChimes", new Method( + name: "PlayChimes", + description: LibrariesResources.Sound_PlayChimes, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayChimesAndWait: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayChimesAndWait' is deprecated."); + } + + methods.Add("PlayChimesAndWait", new Method( + name: "PlayChimesAndWait", + description: LibrariesResources.Sound_PlayChimesAndWait, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayClick: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayClick' is deprecated."); + } + + methods.Add("PlayClick", new Method( + name: "PlayClick", + description: LibrariesResources.Sound_PlayClick, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayClickAndWait: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayClickAndWait' is deprecated."); + } + + methods.Add("PlayClickAndWait", new Method( + name: "PlayClickAndWait", + description: LibrariesResources.Sound_PlayClickAndWait, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.PlayMusic: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.PlayMusic' is deprecated."); + } + + methods.Add("PlayMusic", new Method( + name: "PlayMusic", + description: LibrariesResources.Sound_PlayMusic, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "notes", new Parameter("notes", LibrariesResources.Sound_PlayMusic_notes) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Sound.Stop: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'Sound.Stop' is deprecated."); + } + + methods.Add("Stop", new Method( + name: "Stop", + description: LibrariesResources.Sound_Stop, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "filePath", new Parameter("filePath", LibrariesResources.Sound_Stop_filePath) }, + }, + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Sound", new Library("Sound", LibrariesResources.Sound, "volume-up", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Stack' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Stack.GetCount: + { + Task execute(SmallBasicEngine engine) + { + string stackName = engine.EvaluationStack.Pop().ToString(); + decimal returnValue = engine.Libraries.Stack.GetCount(stackName: stackName); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetCount", new Method( + name: "GetCount", + description: LibrariesResources.Stack_GetCount, + returnsValue: true, + returnValueDescription: LibrariesResources.Stack_GetCount_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "stackName", new Parameter("stackName", LibrariesResources.Stack_GetCount_stackName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Stack.PopValue: + { + Task execute(SmallBasicEngine engine) + { + string stackName = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Stack.PopValue(stackName: stackName); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("PopValue", new Method( + name: "PopValue", + description: LibrariesResources.Stack_PopValue, + returnsValue: true, + returnValueDescription: LibrariesResources.Stack_PopValue_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "stackName", new Parameter("stackName", LibrariesResources.Stack_PopValue_stackName) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Stack.PushValue: + { + Task execute(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + string stackName = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.Stack.PushValue(stackName: stackName, value: value); + return Task.CompletedTask; + } + + methods.Add("PushValue", new Method( + name: "PushValue", + description: LibrariesResources.Stack_PushValue, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "stackName", new Parameter("stackName", LibrariesResources.Stack_PushValue_stackName) }, + { "value", new Parameter("value", LibrariesResources.Stack_PushValue_value) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Stack", new Library("Stack", LibrariesResources.Stack, "ellipsis-v", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Text' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Text.Append: + { + Task execute(SmallBasicEngine engine) + { + string text2 = engine.EvaluationStack.Pop().ToString(); + string text1 = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Text.Append(text1: text1, text2: text2); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Append", new Method( + name: "Append", + description: LibrariesResources.Text_Append, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_Append_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text1", new Parameter("text1", LibrariesResources.Text_Append_text1) }, + { "text2", new Parameter("text2", LibrariesResources.Text_Append_text2) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.ConvertToLowerCase: + { + Task execute(SmallBasicEngine engine) + { + string text = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Text.ConvertToLowerCase(text: text); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("ConvertToLowerCase", new Method( + name: "ConvertToLowerCase", + description: LibrariesResources.Text_ConvertToLowerCase, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_ConvertToLowerCase_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Text_ConvertToLowerCase_text) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.ConvertToUpperCase: + { + Task execute(SmallBasicEngine engine) + { + string text = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Text.ConvertToUpperCase(text: text); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("ConvertToUpperCase", new Method( + name: "ConvertToUpperCase", + description: LibrariesResources.Text_ConvertToUpperCase, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_ConvertToUpperCase_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Text_ConvertToUpperCase_text) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.EndsWith: + { + Task execute(SmallBasicEngine engine) + { + string subText = engine.EvaluationStack.Pop().ToString(); + string text = engine.EvaluationStack.Pop().ToString(); + bool returnValue = engine.Libraries.Text.EndsWith(text: text, subText: subText); + engine.EvaluationStack.Push(new BooleanValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("EndsWith", new Method( + name: "EndsWith", + description: LibrariesResources.Text_EndsWith, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_EndsWith_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Text_EndsWith_text) }, + { "subText", new Parameter("subText", LibrariesResources.Text_EndsWith_subText) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.GetCharacter: + { + Task execute(SmallBasicEngine engine) + { + decimal characterCode = engine.EvaluationStack.Pop().ToNumber(); + string returnValue = engine.Libraries.Text.GetCharacter(characterCode: characterCode); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetCharacter", new Method( + name: "GetCharacter", + description: LibrariesResources.Text_GetCharacter, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_GetCharacter_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "characterCode", new Parameter("characterCode", LibrariesResources.Text_GetCharacter_characterCode) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.GetCharacterCode: + { + Task execute(SmallBasicEngine engine) + { + string character = engine.EvaluationStack.Pop().ToString(); + decimal returnValue = engine.Libraries.Text.GetCharacterCode(character: character); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetCharacterCode", new Method( + name: "GetCharacterCode", + description: LibrariesResources.Text_GetCharacterCode, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_GetCharacterCode_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "character", new Parameter("character", LibrariesResources.Text_GetCharacterCode_character) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.GetIndexOf: + { + Task execute(SmallBasicEngine engine) + { + string subText = engine.EvaluationStack.Pop().ToString(); + string text = engine.EvaluationStack.Pop().ToString(); + decimal returnValue = engine.Libraries.Text.GetIndexOf(text: text, subText: subText); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetIndexOf", new Method( + name: "GetIndexOf", + description: LibrariesResources.Text_GetIndexOf, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_GetIndexOf_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Text_GetIndexOf_text) }, + { "subText", new Parameter("subText", LibrariesResources.Text_GetIndexOf_subText) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.GetLength: + { + Task execute(SmallBasicEngine engine) + { + string text = engine.EvaluationStack.Pop().ToString(); + decimal returnValue = engine.Libraries.Text.GetLength(text: text); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetLength", new Method( + name: "GetLength", + description: LibrariesResources.Text_GetLength, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_GetLength_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Text_GetLength_text) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.GetSubText: + { + Task execute(SmallBasicEngine engine) + { + decimal length = engine.EvaluationStack.Pop().ToNumber(); + decimal start = engine.EvaluationStack.Pop().ToNumber(); + string text = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Text.GetSubText(text: text, start: start, length: length); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetSubText", new Method( + name: "GetSubText", + description: LibrariesResources.Text_GetSubText, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_GetSubText_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Text_GetSubText_text) }, + { "start", new Parameter("start", LibrariesResources.Text_GetSubText_start) }, + { "length", new Parameter("length", LibrariesResources.Text_GetSubText_length) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.GetSubTextToEnd: + { + Task execute(SmallBasicEngine engine) + { + decimal start = engine.EvaluationStack.Pop().ToNumber(); + string text = engine.EvaluationStack.Pop().ToString(); + string returnValue = engine.Libraries.Text.GetSubTextToEnd(text: text, start: start); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("GetSubTextToEnd", new Method( + name: "GetSubTextToEnd", + description: LibrariesResources.Text_GetSubTextToEnd, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_GetSubTextToEnd_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Text_GetSubTextToEnd_text) }, + { "start", new Parameter("start", LibrariesResources.Text_GetSubTextToEnd_start) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.IsSubText: + { + Task execute(SmallBasicEngine engine) + { + string subText = engine.EvaluationStack.Pop().ToString(); + string text = engine.EvaluationStack.Pop().ToString(); + bool returnValue = engine.Libraries.Text.IsSubText(text: text, subText: subText); + engine.EvaluationStack.Push(new BooleanValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("IsSubText", new Method( + name: "IsSubText", + description: LibrariesResources.Text_IsSubText, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_IsSubText_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Text_IsSubText_text) }, + { "subText", new Parameter("subText", LibrariesResources.Text_IsSubText_subText) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Text.StartsWith: + { + Task execute(SmallBasicEngine engine) + { + string subText = engine.EvaluationStack.Pop().ToString(); + string text = engine.EvaluationStack.Pop().ToString(); + bool returnValue = engine.Libraries.Text.StartsWith(text: text, subText: subText); + engine.EvaluationStack.Push(new BooleanValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("StartsWith", new Method( + name: "StartsWith", + description: LibrariesResources.Text_StartsWith, + returnsValue: true, + returnValueDescription: LibrariesResources.Text_StartsWith_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "text", new Parameter("text", LibrariesResources.Text_StartsWith_text) }, + { "subText", new Parameter("subText", LibrariesResources.Text_StartsWith_subText) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Text", new Library("Text", LibrariesResources.Text, "text-height", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'TextWindow' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method TextWindow.Clear: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.TextWindow.Clear(); + return Task.CompletedTask; + } + + methods.Add("Clear", new Method( + name: "Clear", + description: LibrariesResources.TextWindow_Clear, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method TextWindow.Hide: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'TextWindow.Hide' is deprecated."); + } + + methods.Add("Hide", new Method( + name: "Hide", + description: LibrariesResources.TextWindow_Hide, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method TextWindow.Pause: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'TextWindow.Pause' is deprecated."); + } + + methods.Add("Pause", new Method( + name: "Pause", + description: LibrariesResources.TextWindow_Pause, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method TextWindow.PauseIfVisible: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'TextWindow.PauseIfVisible' is deprecated."); + } + + methods.Add("PauseIfVisible", new Method( + name: "PauseIfVisible", + description: LibrariesResources.TextWindow_PauseIfVisible, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method TextWindow.PauseWithoutMessage: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'TextWindow.PauseWithoutMessage' is deprecated."); + } + + methods.Add("PauseWithoutMessage", new Method( + name: "PauseWithoutMessage", + description: LibrariesResources.TextWindow_PauseWithoutMessage, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method TextWindow.Read: + { + Task execute(SmallBasicEngine engine) + { + string returnValue = engine.Libraries.TextWindow.Read(); + engine.EvaluationStack.Push(StringValue.Create(returnValue)); + return Task.CompletedTask; + } + + methods.Add("Read", new Method( + name: "Read", + description: LibrariesResources.TextWindow_Read, + returnsValue: true, + returnValueDescription: LibrariesResources.TextWindow_Read_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method TextWindow.ReadNumber: + { + Task execute(SmallBasicEngine engine) + { + decimal returnValue = engine.Libraries.TextWindow.ReadNumber(); + engine.EvaluationStack.Push(new NumberValue(returnValue)); + return Task.CompletedTask; + } + + methods.Add("ReadNumber", new Method( + name: "ReadNumber", + description: LibrariesResources.TextWindow_ReadNumber, + returnsValue: true, + returnValueDescription: LibrariesResources.TextWindow_ReadNumber_ReturnValue, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method TextWindow.Show: + { + Task execute(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library method 'TextWindow.Show' is deprecated."); + } + + methods.Add("Show", new Method( + name: "Show", + description: LibrariesResources.TextWindow_Show, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: true, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method TextWindow.Write: + { + Task execute(SmallBasicEngine engine) + { + string data = engine.EvaluationStack.Pop().ToString(); + return engine.Libraries.TextWindow.Write(data: data); + } + + methods.Add("Write", new Method( + name: "Write", + description: LibrariesResources.TextWindow_Write, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "data", new Parameter("data", LibrariesResources.TextWindow_Write_data) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method TextWindow.WriteLine: + { + Task execute(SmallBasicEngine engine) + { + string data = engine.EvaluationStack.Pop().ToString(); + return engine.Libraries.TextWindow.WriteLine(data: data); + } + + methods.Add("WriteLine", new Method( + name: "WriteLine", + description: LibrariesResources.TextWindow_WriteLine, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "data", new Parameter("data", LibrariesResources.TextWindow_WriteLine_data) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property TextWindow.BackgroundColor: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.TextWindow.Get_BackgroundColor(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.TextWindow.Set_BackgroundColor(value); + return Task.CompletedTask; + } + + properties.Add("BackgroundColor", new Property("BackgroundColor", LibrariesResources.TextWindow_BackgroundColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property TextWindow.CursorLeft: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'TextWindow.CursorLeft' is deprecated."); + } + + Task setter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'TextWindow.CursorLeft' is deprecated."); + } + + properties.Add("CursorLeft", new Property("CursorLeft", LibrariesResources.TextWindow_CursorLeft, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property TextWindow.CursorTop: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'TextWindow.CursorTop' is deprecated."); + } + + Task setter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'TextWindow.CursorTop' is deprecated."); + } + + properties.Add("CursorTop", new Property("CursorTop", LibrariesResources.TextWindow_CursorTop, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property TextWindow.ForegroundColor: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.TextWindow.Get_ForegroundColor(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.TextWindow.Set_ForegroundColor(value); + return Task.CompletedTask; + } + + properties.Add("ForegroundColor", new Property("ForegroundColor", LibrariesResources.TextWindow_ForegroundColor, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property TextWindow.Left: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'TextWindow.Left' is deprecated."); + } + + Task setter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'TextWindow.Left' is deprecated."); + } + + properties.Add("Left", new Property("Left", LibrariesResources.TextWindow_Left, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property TextWindow.Title: + { + Task getter(SmallBasicEngine engine) + { + string value = engine.Libraries.TextWindow.Get_Title(); + engine.EvaluationStack.Push(StringValue.Create(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + string value = engine.EvaluationStack.Pop().ToString(); + engine.Libraries.TextWindow.Set_Title(value); + return Task.CompletedTask; + } + + properties.Add("Title", new Property("Title", LibrariesResources.TextWindow_Title, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property TextWindow.Top: + { + Task getter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'TextWindow.Top' is deprecated."); + } + + Task setter(SmallBasicEngine engine) + { + throw new InvalidOperationException("Library property 'TextWindow.Top' is deprecated."); + } + + properties.Add("Top", new Property("Top", LibrariesResources.TextWindow_Top, isDeprecated: true, needsDesktop: false, getter: getter, setter: setter)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("TextWindow", new Library("TextWindow", LibrariesResources.TextWindow, "terminal", usesGraphicsWindow: false, usesTextWindow: true, methods, properties, events)); + } + + // Initialization code for library 'Timer' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Timer.Pause: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Timer.Pause(); + return Task.CompletedTask; + } + + methods.Add("Pause", new Method( + name: "Pause", + description: LibrariesResources.Timer_Pause, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Timer.Resume: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Timer.Resume(); + return Task.CompletedTask; + } + + methods.Add("Resume", new Method( + name: "Resume", + description: LibrariesResources.Timer_Resume, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property Timer.Interval: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Timer.Get_Interval(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + decimal value = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.Timer.Set_Interval(value); + return Task.CompletedTask; + } + + properties.Add("Interval", new Property("Interval", LibrariesResources.Timer_Interval, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "Tick", new Event("Tick", LibrariesResources.Timer_Tick) }, + }; + + types.Add("Timer", new Library("Timer", LibrariesResources.Timer, "stopwatch", usesGraphicsWindow: false, usesTextWindow: false, methods, properties, events)); + } + + // Initialization code for library 'Turtle' + { + var methods = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for method Turtle.Hide: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Turtle.Hide(); + return Task.CompletedTask; + } + + methods.Add("Hide", new Method( + name: "Hide", + description: LibrariesResources.Turtle_Hide, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Turtle.Move: + { + Task execute(SmallBasicEngine engine) + { + decimal distance = engine.EvaluationStack.Pop().ToNumber(); + return engine.Libraries.Turtle.Move(distance: distance); + } + + methods.Add("Move", new Method( + name: "Move", + description: LibrariesResources.Turtle_Move, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "distance", new Parameter("distance", LibrariesResources.Turtle_Move_distance) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Turtle.MoveTo: + { + Task execute(SmallBasicEngine engine) + { + decimal y = engine.EvaluationStack.Pop().ToNumber(); + decimal x = engine.EvaluationStack.Pop().ToNumber(); + return engine.Libraries.Turtle.MoveTo(x: x, y: y); + } + + methods.Add("MoveTo", new Method( + name: "MoveTo", + description: LibrariesResources.Turtle_MoveTo, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "x", new Parameter("x", LibrariesResources.Turtle_MoveTo_x) }, + { "y", new Parameter("y", LibrariesResources.Turtle_MoveTo_y) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Turtle.PenDown: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Turtle.PenDown(); + return Task.CompletedTask; + } + + methods.Add("PenDown", new Method( + name: "PenDown", + description: LibrariesResources.Turtle_PenDown, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Turtle.PenUp: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Turtle.PenUp(); + return Task.CompletedTask; + } + + methods.Add("PenUp", new Method( + name: "PenUp", + description: LibrariesResources.Turtle_PenUp, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Turtle.Show: + { + Task execute(SmallBasicEngine engine) + { + engine.Libraries.Turtle.Show(); + return Task.CompletedTask; + } + + methods.Add("Show", new Method( + name: "Show", + description: LibrariesResources.Turtle_Show, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Turtle.Turn: + { + Task execute(SmallBasicEngine engine) + { + decimal angle = engine.EvaluationStack.Pop().ToNumber(); + return engine.Libraries.Turtle.Turn(angle: angle); + } + + methods.Add("Turn", new Method( + name: "Turn", + description: LibrariesResources.Turtle_Turn, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase) + { + { "angle", new Parameter("angle", LibrariesResources.Turtle_Turn_angle) }, + }, + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Turtle.TurnLeft: + { + Task execute(SmallBasicEngine engine) + { + return engine.Libraries.Turtle.TurnLeft(); + } + + methods.Add("TurnLeft", new Method( + name: "TurnLeft", + description: LibrariesResources.Turtle_TurnLeft, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + // Initialization code for method Turtle.TurnRight: + { + Task execute(SmallBasicEngine engine) + { + return engine.Libraries.Turtle.TurnRight(); + } + + methods.Add("TurnRight", new Method( + name: "TurnRight", + description: LibrariesResources.Turtle_TurnRight, + returnsValue: false, + returnValueDescription: null, + parameters: new Dictionary(StringComparer.CurrentCultureIgnoreCase), + isDeprecated: false, + needsDesktop: false, + execute: execute)); + } + + var properties = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + // Initialization code for property Turtle.Angle: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Turtle.Get_Angle(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + decimal value = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.Turtle.Set_Angle(value); + return Task.CompletedTask; + } + + properties.Add("Angle", new Property("Angle", LibrariesResources.Turtle_Angle, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property Turtle.Speed: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Turtle.Get_Speed(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + decimal value = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.Turtle.Set_Speed(value); + return Task.CompletedTask; + } + + properties.Add("Speed", new Property("Speed", LibrariesResources.Turtle_Speed, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property Turtle.X: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Turtle.Get_X(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + decimal value = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.Turtle.Set_X(value); + return Task.CompletedTask; + } + + properties.Add("X", new Property("X", LibrariesResources.Turtle_X, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + // Initialization code for property Turtle.Y: + { + Task getter(SmallBasicEngine engine) + { + decimal value = engine.Libraries.Turtle.Get_Y(); + engine.EvaluationStack.Push(new NumberValue(value)); + return Task.CompletedTask; + } + + Task setter(SmallBasicEngine engine) + { + decimal value = engine.EvaluationStack.Pop().ToNumber(); + engine.Libraries.Turtle.Set_Y(value); + return Task.CompletedTask; + } + + properties.Add("Y", new Property("Y", LibrariesResources.Turtle_Y, isDeprecated: false, needsDesktop: false, getter: getter, setter: setter)); + } + + var events = new Dictionary(StringComparer.CurrentCultureIgnoreCase); + + types.Add("Turtle", new Library("Turtle", LibrariesResources.Turtle, "pen-alt", usesGraphicsWindow: true, usesTextWindow: false, methods, properties, events)); + } + + Types = types; + } + } +} diff --git a/Source/SmallBasic.Compiler/Runtime/Libraries/Libraries.Interfaces.Generated.cs b/Source/SmallBasic.Compiler/Runtime/Libraries/Libraries.Interfaces.Generated.cs index 538db42b..3553429b 100644 --- a/Source/SmallBasic.Compiler/Runtime/Libraries/Libraries.Interfaces.Generated.cs +++ b/Source/SmallBasic.Compiler/Runtime/Libraries/Libraries.Interfaces.Generated.cs @@ -1,539 +1,549 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Compiler.Runtime -{ - using System; - using System.Threading.Tasks; - - public interface IArrayLibrary - { - bool ContainsIndex(ArrayValue array, string index); - - bool ContainsValue(ArrayValue array, string value); - - ArrayValue GetAllIndices(ArrayValue array); - - decimal GetItemCount(ArrayValue array); - - BaseValue GetValue(string arrayName, string index); - - bool IsArray(BaseValue array); - - void RemoveValue(string arrayName, string index); - - void SetValue(string arrayName, string index, BaseValue value); - } - - public interface IClockLibrary - { - string Get_Date(); - - decimal Get_Day(); - - decimal Get_ElapsedMilliseconds(); - - decimal Get_Hour(); - - decimal Get_Millisecond(); - - decimal Get_Minute(); - - decimal Get_Month(); - - decimal Get_Second(); - - string Get_Time(); - - string Get_WeekDay(); - - decimal Get_Year(); - } - - public interface IControlsLibrary - { - event Action ButtonClicked; - - event Action TextTyped; - - string Get_LastClickedButton(); - - string Get_LastTypedTextBox(); - - string AddButton(string caption, decimal left, decimal top); - - string AddMultiLineTextBox(decimal left, decimal top); - - string AddTextBox(decimal left, decimal top); - - string GetButtonCaption(string buttonName); - - string GetTextBoxText(string textBoxName); - - void HideControl(string controlName); - - void Move(string control, decimal x, decimal y); - - void Remove(string controlName); - - void SetButtonCaption(string buttonName, string caption); - - void SetSize(string control, decimal width, decimal height); - - void SetTextBoxText(string textBoxName, string text); - - void ShowControl(string controlName); - } - - public interface IDesktopLibrary - { - } - - public interface IDictionaryLibrary - { - } - - public interface IFileLibrary - { - string Get_LastError(); - - void Set_LastError(string value); - - Task AppendContents(string filePath, string contents); - - Task CopyFile(string sourceFilePath, string destinationFilePath); - - Task CreateDirectory(string directoryPath); - - Task DeleteDirectory(string directoryPath); - - Task DeleteFile(string filePath); - - Task GetDirectories(string directoryPath); - - Task GetFiles(string directoryPath); - - Task GetTemporaryFilePath(); - - Task InsertLine(string filePath, decimal lineNumber, string contents); - - Task ReadContents(string filePath); - - Task ReadLine(string filePath, decimal lineNumber); - - Task WriteContents(string filePath, string contents); - - Task WriteLine(string filePath, decimal lineNumber, string contents); - } - - public interface IFlickrLibrary - { - } - - public interface IGraphicsWindowLibrary - { - event Action KeyDown; - - event Action KeyUp; - - event Action MouseDown; - - event Action MouseMove; - - event Action MouseUp; - - event Action TextInput; - - string Get_BackgroundColor(); - - void Set_BackgroundColor(string value); - - string Get_BrushColor(); - - void Set_BrushColor(string value); - - bool Get_FontBold(); - - void Set_FontBold(bool value); - - bool Get_FontItalic(); - - void Set_FontItalic(bool value); - - string Get_FontName(); - - void Set_FontName(string value); - - decimal Get_FontSize(); - - void Set_FontSize(decimal value); - - Task Get_Height(); - - Task Set_Height(decimal value); - - string Get_LastKey(); - - string Get_LastText(); - - decimal Get_MouseX(); - - decimal Get_MouseY(); - - string Get_PenColor(); - - void Set_PenColor(string value); - - decimal Get_PenWidth(); - - void Set_PenWidth(decimal value); - - string Get_Title(); - - void Set_Title(string value); - - Task Get_Width(); - - Task Set_Width(decimal value); - - void Clear(); - - void DrawBoundText(decimal x, decimal y, decimal width, string text); - - void DrawEllipse(decimal x, decimal y, decimal width, decimal height); - - void DrawImage(string imageName, decimal x, decimal y); - - void DrawLine(decimal x1, decimal y1, decimal x2, decimal y2); - - void DrawRectangle(decimal x, decimal y, decimal width, decimal height); - - void DrawResizedImage(string imageName, decimal x, decimal y, decimal width, decimal height); - - void DrawText(decimal x, decimal y, string text); - - void DrawTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3); - - void FillEllipse(decimal x, decimal y, decimal width, decimal height); - - void FillRectangle(decimal x, decimal y, decimal width, decimal height); - - void FillTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3); - - string GetColorFromRGB(decimal red, decimal green, decimal blue); - - string GetRandomColor(); - - void Hide(); - - void SetPixel(decimal x, decimal y, string color); - - void Show(); - - Task ShowMessage(string text, string title); - } - - public interface IImageListLibrary - { - decimal GetHeightOfImage(string imageName); - - decimal GetWidthOfImage(string imageName); - - Task LoadImage(string fileNameOrUrl); - } - - public interface IMathLibrary - { - decimal Get_Pi(); - - decimal Abs(decimal number); - - decimal ArcCos(decimal cosValue); - - decimal ArcSin(decimal sinValue); - - decimal ArcTan(decimal tanValue); - - decimal Ceiling(decimal number); - - decimal Cos(decimal angle); - - decimal Floor(decimal number); - - decimal GetDegrees(decimal angle); - - decimal GetRadians(decimal angle); - - decimal GetRandomNumber(decimal maxNumber); - - decimal Log(decimal number); - - decimal Max(decimal number1, decimal number2); - - decimal Min(decimal number1, decimal number2); - - decimal NaturalLog(decimal number); - - decimal Power(decimal baseNumber, decimal exponent); - - decimal Remainder(decimal dividend, decimal divisor); - - decimal Round(decimal number); - - decimal Sin(decimal angle); - - decimal SquareRoot(decimal number); - - decimal Tan(decimal angle); - } - - public interface IMouseLibrary - { - bool Get_IsLeftButtonDown(); - - bool Get_IsRightButtonDown(); - - decimal Get_MouseX(); - - decimal Get_MouseY(); - - void HideCursor(); - - void ShowCursor(); - } - - public interface INetworkLibrary - { - Task DownloadFile(string url); - - Task GetWebPageContents(string url); - } - - public interface IProgramLibrary - { - Task Delay(decimal milliSeconds); - - void End(); - - void Pause(); - } - - public interface IShapesLibrary - { - string AddEllipse(decimal width, decimal height); - - string AddImage(string imageName); - - string AddLine(decimal x1, decimal y1, decimal x2, decimal y2); - - string AddRectangle(decimal width, decimal height); - - string AddText(string text); - - string AddTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3); - - Task Animate(string shapeName, decimal x, decimal y, decimal duration); - - decimal GetLeft(string shapeName); - - decimal GetOpacity(string shapeName); - - decimal GetTop(string shapeName); - - void HideShape(string shapeName); - - void Move(string shapeName, decimal x, decimal y); - - void Remove(string shapeName); - - void Rotate(string shapeName, decimal angle); - - void SetOpacity(string shapeName, decimal level); - - void SetText(string shapeName, string text); - - void ShowShape(string shapeName); - - void Zoom(string shapeName, decimal scaleX, decimal scaleY); - } - - public interface ISoundLibrary - { - } - - public interface IStackLibrary - { - decimal GetCount(string stackName); - - string PopValue(string stackName); - - void PushValue(string stackName, string value); - } - - public interface ITextLibrary - { - string Append(string text1, string text2); - - string ConvertToLowerCase(string text); - - string ConvertToUpperCase(string text); - - bool EndsWith(string text, string subText); - - string GetCharacter(decimal characterCode); - - decimal GetCharacterCode(string character); - - decimal GetIndexOf(string text, string subText); - - decimal GetLength(string text); - - string GetSubText(string text, decimal start, decimal length); - - string GetSubTextToEnd(string text, decimal start); - - bool IsSubText(string text, string subText); - - bool StartsWith(string text, string subText); - } - - public interface ITextWindowLibrary - { - string Get_BackgroundColor(); - - void Set_BackgroundColor(string value); - - string Get_ForegroundColor(); - - void Set_ForegroundColor(string value); - - string Get_Title(); - - void Set_Title(string value); - - void Clear(); - - string Read(); - - decimal ReadNumber(); - - Task Write(string data); - - Task WriteLine(string data); - } - - public interface ITimerLibrary - { - event Action Tick; - - decimal Get_Interval(); - - void Set_Interval(decimal value); - - void Pause(); - - void Resume(); - } - - public interface ITurtleLibrary - { - decimal Get_Angle(); - - void Set_Angle(decimal value); - - decimal Get_Speed(); - - void Set_Speed(decimal value); - - decimal Get_X(); - - void Set_X(decimal value); - - decimal Get_Y(); - - void Set_Y(decimal value); - - void Hide(); - - Task Move(decimal distance); - - Task MoveTo(decimal x, decimal y); - - void PenDown(); - - void PenUp(); - - void Show(); - - Task Turn(decimal angle); - - Task TurnLeft(); - - Task TurnRight(); - } - - public interface IEngineLibraries - { - IArrayLibrary Array { get; } - - IClockLibrary Clock { get; } - - IControlsLibrary Controls { get; } - - IDesktopLibrary Desktop { get; } - - IDictionaryLibrary Dictionary { get; } - - IFileLibrary File { get; } - - IFlickrLibrary Flickr { get; } - - IGraphicsWindowLibrary GraphicsWindow { get; } - - IImageListLibrary ImageList { get; } - - IMathLibrary Math { get; } - - IMouseLibrary Mouse { get; } - - INetworkLibrary Network { get; } - - IProgramLibrary Program { get; } - - IShapesLibrary Shapes { get; } - - ISoundLibrary Sound { get; } - - IStackLibrary Stack { get; } - - ITextLibrary Text { get; } - - ITextWindowLibrary TextWindow { get; } - - ITimerLibrary Timer { get; } - - ITurtleLibrary Turtle { get; } - } - - internal static class IEngineLibrariesExtensions - { - public static void SetEventCallbacks(this IEngineLibraries libraries, SmallBasicEngine engine) - { - libraries.Controls.ButtonClicked += () => engine.RaiseEvent("Controls", "ButtonClicked"); - libraries.Controls.TextTyped += () => engine.RaiseEvent("Controls", "TextTyped"); - - libraries.GraphicsWindow.KeyDown += () => engine.RaiseEvent("GraphicsWindow", "KeyDown"); - libraries.GraphicsWindow.KeyUp += () => engine.RaiseEvent("GraphicsWindow", "KeyUp"); - libraries.GraphicsWindow.MouseDown += () => engine.RaiseEvent("GraphicsWindow", "MouseDown"); - libraries.GraphicsWindow.MouseMove += () => engine.RaiseEvent("GraphicsWindow", "MouseMove"); - libraries.GraphicsWindow.MouseUp += () => engine.RaiseEvent("GraphicsWindow", "MouseUp"); - libraries.GraphicsWindow.TextInput += () => engine.RaiseEvent("GraphicsWindow", "TextInput"); - - libraries.Timer.Tick += () => engine.RaiseEvent("Timer", "Tick"); - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Compiler.Runtime +{ + using System; + using System.Threading.Tasks; + using SmallBasic.Utilities; + + public interface IArrayLibrary + { + bool ContainsIndex(ArrayValue array, string index); + + bool ContainsValue(ArrayValue array, string value); + + ArrayValue GetAllIndices(ArrayValue array); + + decimal GetItemCount(ArrayValue array); + + BaseValue GetValue(string arrayName, string index); + + bool IsArray(BaseValue array); + + void RemoveValue(string arrayName, string index); + + void SetValue(string arrayName, string index, BaseValue value); + } + + public interface IClockLibrary + { + string Get_Date(); + + decimal Get_Day(); + + decimal Get_ElapsedMilliseconds(); + + decimal Get_Hour(); + + decimal Get_Millisecond(); + + decimal Get_Minute(); + + decimal Get_Month(); + + decimal Get_Second(); + + string Get_Time(); + + string Get_WeekDay(); + + decimal Get_Year(); + } + + public interface IControlsLibrary + { + event Action ButtonClicked; + + event Action TextTyped; + + string Get_LastClickedButton(); + + string Get_LastTypedTextBox(); + + string AddButton(string caption, decimal left, decimal top); + + string AddMultiLineTextBox(decimal left, decimal top); + + string AddTextBox(decimal left, decimal top); + + string GetButtonCaption(string buttonName); + + string GetTextBoxText(string textBoxName); + + void HideControl(string controlName); + + void Move(string control, decimal x, decimal y); + + void Remove(string controlName); + + void SetButtonCaption(string buttonName, string caption); + + void SetSize(string control, decimal width, decimal height); + + void SetTextBoxText(string textBoxName, string text); + + void ShowControl(string controlName); + } + + public interface IDesktopLibrary + { + } + + public interface IDictionaryLibrary + { + } + + public interface IFileLibrary + { + string Get_LastError(); + + void Set_LastError(string value); + + Task AppendContents(string filePath, string contents); + + Task CopyFile(string sourceFilePath, string destinationFilePath); + + Task CreateDirectory(string directoryPath); + + Task DeleteDirectory(string directoryPath); + + Task DeleteFile(string filePath); + + Task GetDirectories(string directoryPath); + + Task GetFiles(string directoryPath); + + Task GetTemporaryFilePath(); + + Task InsertLine(string filePath, decimal lineNumber, string contents); + + Task ReadContents(string filePath); + + Task ReadLine(string filePath, decimal lineNumber); + + Task WriteContents(string filePath, string contents); + + Task WriteLine(string filePath, decimal lineNumber, string contents); + } + + public interface IFlickrLibrary + { + } + + public interface IGraphicsWindowLibrary + { + event Action KeyDown; + + event Action KeyUp; + + event Action MouseDown; + + event Action MouseMove; + + event Action MouseUp; + + event Action TextInput; + + string Get_BackgroundColor(); + + void Set_BackgroundColor(string value); + + string Get_BrushColor(); + + void Set_BrushColor(string value); + + bool Get_FontBold(); + + void Set_FontBold(bool value); + + bool Get_FontItalic(); + + void Set_FontItalic(bool value); + + string Get_FontName(); + + void Set_FontName(string value); + + decimal Get_FontSize(); + + void Set_FontSize(decimal value); + + Task Get_Height(); + + Task Set_Height(decimal value); + + string Get_LastKey(); + + string Get_LastText(); + + decimal Get_MouseX(); + + decimal Get_MouseY(); + + string Get_PenColor(); + + void Set_PenColor(string value); + + decimal Get_PenWidth(); + + void Set_PenWidth(decimal value); + + string Get_Title(); + + void Set_Title(string value); + + Task Get_Width(); + + Task Set_Width(decimal value); + + void Clear(); + + void DrawBoundText(decimal x, decimal y, decimal width, string text); + + void DrawEllipse(decimal x, decimal y, decimal width, decimal height); + + void DrawImage(string imageName, decimal x, decimal y); + + void DrawLine(decimal x1, decimal y1, decimal x2, decimal y2); + + void DrawRectangle(decimal x, decimal y, decimal width, decimal height); + + void DrawResizedImage(string imageName, decimal x, decimal y, decimal width, decimal height); + + void DrawText(decimal x, decimal y, string text); + + void DrawTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3); + + void FillEllipse(decimal x, decimal y, decimal width, decimal height); + + void FillRectangle(decimal x, decimal y, decimal width, decimal height); + + void FillTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3); + + string GetColorFromRGB(decimal red, decimal green, decimal blue); + + string GetRandomColor(); + + void Hide(); + + void SetPixel(decimal x, decimal y, string color); + + void Show(); + + Task ShowMessage(string text, string title); + } + + public interface IImageListLibrary + { + decimal GetHeightOfImage(string imageName); + + decimal GetWidthOfImage(string imageName); + + Task LoadImage(string fileNameOrUrl); + } + + public interface IMathLibrary + { + decimal Get_Pi(); + + decimal Abs(decimal number); + + decimal ArcCos(decimal cosValue); + + decimal ArcSin(decimal sinValue); + + decimal ArcTan(decimal tanValue); + + decimal Ceiling(decimal number); + + decimal Cos(decimal angle); + + decimal Floor(decimal number); + + decimal GetDegrees(decimal angle); + + decimal GetRadians(decimal angle); + + decimal GetRandomNumber(decimal maxNumber); + + decimal Log(decimal number); + + decimal Max(decimal number1, decimal number2); + + decimal Min(decimal number1, decimal number2); + + decimal NaturalLog(decimal number); + + decimal Power(decimal baseNumber, decimal exponent); + + decimal Remainder(decimal dividend, decimal divisor); + + decimal Round(decimal number); + + decimal Sin(decimal angle); + + decimal SquareRoot(decimal number); + + decimal Tan(decimal angle); + } + + public interface IMouseLibrary + { + bool Get_IsLeftButtonDown(); + + bool Get_IsRightButtonDown(); + + decimal Get_MouseX(); + + decimal Get_MouseY(); + + void HideCursor(); + + void ShowCursor(); + } + + public interface INetworkLibrary + { + Task DownloadFile(string url); + + Task GetWebPageContents(string url); + } + + public interface IProgramLibrary + { + Task Delay(decimal milliSeconds); + + void End(); + + void Pause(); + } + + public interface IShapesLibrary + { + string AddEllipse(decimal width, decimal height); + + string AddImage(string imageName); + + string AddLine(decimal x1, decimal y1, decimal x2, decimal y2); + + string AddRectangle(decimal width, decimal height); + + string AddText(string text); + + string AddTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3); + + Task Animate(string shapeName, decimal x, decimal y, decimal duration); + + decimal GetLeft(string shapeName); + + decimal GetOpacity(string shapeName); + + decimal GetTop(string shapeName); + + void HideShape(string shapeName); + + void Move(string shapeName, decimal x, decimal y); + + void Remove(string shapeName); + + void Rotate(string shapeName, decimal angle); + + void SetOpacity(string shapeName, decimal level); + + void SetText(string shapeName, string text); + + void ShowShape(string shapeName); + + void Zoom(string shapeName, decimal scaleX, decimal scaleY); + } + + public interface ISoundLibrary + { + } + + public interface IStackLibrary + { + decimal GetCount(string stackName); + + string PopValue(string stackName); + + void PushValue(string stackName, string value); + } + + public interface ITextLibrary + { + string Append(string text1, string text2); + + string ConvertToLowerCase(string text); + + string ConvertToUpperCase(string text); + + bool EndsWith(string text, string subText); + + string GetCharacter(decimal characterCode); + + decimal GetCharacterCode(string character); + + decimal GetIndexOf(string text, string subText); + + decimal GetLength(string text); + + string GetSubText(string text, decimal start, decimal length); + + string GetSubTextToEnd(string text, decimal start); + + bool IsSubText(string text, string subText); + + bool StartsWith(string text, string subText); + } + + public interface ITextWindowLibrary + { + string Get_BackgroundColor(); + + void Set_BackgroundColor(string value); + + string Get_ForegroundColor(); + + void Set_ForegroundColor(string value); + + string Get_Title(); + + void Set_Title(string value); + + void Clear(); + + string Read(); + + decimal ReadNumber(); + + Task Write(string data); + + Task WriteLine(string data); + } + + public interface ITimerLibrary + { + event Action Tick; + + decimal Get_Interval(); + + void Set_Interval(decimal value); + + void Pause(); + + void Resume(); + } + + public interface ITurtleLibrary + { + decimal Get_Angle(); + + void Set_Angle(decimal value); + + decimal Get_Speed(); + + void Set_Speed(decimal value); + + decimal Get_X(); + + void Set_X(decimal value); + + decimal Get_Y(); + + void Set_Y(decimal value); + + void Hide(); + + Task Move(decimal distance); + + Task MoveTo(decimal x, decimal y); + + void PenDown(); + + void PenUp(); + + void Show(); + + Task Turn(decimal angle); + + Task TurnLeft(); + + Task TurnRight(); + } + + public interface IEngineLibraries + { + IArrayLibrary Array { get; } + + IClockLibrary Clock { get; } + + IControlsLibrary Controls { get; } + + IDesktopLibrary Desktop { get; } + + IDictionaryLibrary Dictionary { get; } + + IFileLibrary File { get; } + + IFlickrLibrary Flickr { get; } + + IGraphicsWindowLibrary GraphicsWindow { get; } + + IImageListLibrary ImageList { get; } + + IMathLibrary Math { get; } + + IMouseLibrary Mouse { get; } + + INetworkLibrary Network { get; } + + IProgramLibrary Program { get; } + + IShapesLibrary Shapes { get; } + + ISoundLibrary Sound { get; } + + IStackLibrary Stack { get; } + + ITextLibrary Text { get; } + + ITextWindowLibrary TextWindow { get; } + + ITimerLibrary Timer { get; } + + ITurtleLibrary Turtle { get; } + } + + internal static class IEngineLibrariesExtensions + { + public static void SetEventCallbacks(this IEngineLibraries libraries, SmallBasicEngine engine) + { + if (!libraries.Controls.IsDefault()) + { + libraries.Controls.ButtonClicked += () => engine.RaiseEvent("Controls", "ButtonClicked"); + libraries.Controls.TextTyped += () => engine.RaiseEvent("Controls", "TextTyped"); + } + + if (!libraries.GraphicsWindow.IsDefault()) + { + libraries.GraphicsWindow.KeyDown += () => engine.RaiseEvent("GraphicsWindow", "KeyDown"); + libraries.GraphicsWindow.KeyUp += () => engine.RaiseEvent("GraphicsWindow", "KeyUp"); + libraries.GraphicsWindow.MouseDown += () => engine.RaiseEvent("GraphicsWindow", "MouseDown"); + libraries.GraphicsWindow.MouseMove += () => engine.RaiseEvent("GraphicsWindow", "MouseMove"); + libraries.GraphicsWindow.MouseUp += () => engine.RaiseEvent("GraphicsWindow", "MouseUp"); + libraries.GraphicsWindow.TextInput += () => engine.RaiseEvent("GraphicsWindow", "TextInput"); + } + + if (!libraries.Timer.IsDefault()) + { + libraries.Timer.Tick += () => engine.RaiseEvent("Timer", "Tick"); + } + } + } +} diff --git a/Source/SmallBasic.Compiler/Runtime/ModuleEmitter.cs b/Source/SmallBasic.Compiler/Runtime/ModuleEmitter.cs index b7ab9af7..852809c1 100644 --- a/Source/SmallBasic.Compiler/Runtime/ModuleEmitter.cs +++ b/Source/SmallBasic.Compiler/Runtime/ModuleEmitter.cs @@ -1,4 +1,4 @@ -// +// // Licensed under the MIT License. See LICENSE file in the project root for license information. // @@ -29,19 +29,72 @@ private void EmitStatement(BaseBoundStatement statement) { switch (statement) { - case BoundStatementBlock blockStatement: this.EmitBlockStatement(blockStatement); break; - case BoundIfStatement ifStatement: this.EmitIfStatement(ifStatement); break; - case BoundWhileStatement whileStatement: this.EmitWhileStatement(whileStatement); break; - case BoundForStatement forStatement: this.EmitForStatement(forStatement); break; - case BoundLabelStatement labelStatement: this.EmitLabelStatement(labelStatement); break; - case BoundGoToStatement goToStatement: this.EmitGoToStatement(goToStatement); break; - case BoundSubModuleInvocationStatement subModuleInvocationStatement: this.EmitSubModuleInvocationStatement(subModuleInvocationStatement); break; - case BoundLibraryMethodInvocationStatement libraryMethodInvocaationStatement: this.EmitLibraryMethodInvocationStatement(libraryMethodInvocaationStatement); break; - case BoundEventAssignmentStatement eventAssignmentStatement: this.EmitEventAssignmentStatement(eventAssignmentStatement); break; - case BoundVariableAssignmentStatement variableAssignmentStatement: this.EmitVariableAssignmentStatement(variableAssignmentStatement); break; - case BoundPropertyAssignmentStatement propertyAssignmentStatement: this.EmitPropertyAssignmentStatement(propertyAssignmentStatement); break; - case BoundArrayAssignmentStatement arrayAssignmentStatement: this.EmitArrayAssignmentStatement(arrayAssignmentStatement); break; - default: throw ExceptionUtilities.UnexpectedValue(statement); + case BoundStatementBlock blockStatement: + this.EmitBlockStatement(blockStatement); + break; + + case BoundIfStatement ifStatement: + this.EmitIfStatement(ifStatement); + break; + + case BoundWhileStatement whileStatement: + this.EmitWhileStatement(whileStatement); + break; + + case BoundForStatement forStatement: + this.EmitForStatement(forStatement); + break; + + case BoundForEachStatement forEachStatement: + this.EmitForEachStatement(forEachStatement); + break; + + case BoundSelectStatement selectStatement: + this.EmitSelectStatement(selectStatement); + break; + + case BoundTryStatement tryStatement: + this.EmitTryStatement(tryStatement); + break; + + case BoundLabelStatement labelStatement: + this.EmitLabelStatement(labelStatement); + break; + + case BoundGoToStatement goToStatement: + this.EmitGoToStatement(goToStatement); + break; + + case BoundReturnStatement returnStatement: + this.EmitReturnStatement(returnStatement); + break; + + case BoundSubModuleInvocationStatement subModuleInvocationStatement: + this.EmitSubModuleInvocationStatement(subModuleInvocationStatement); + break; + + case BoundLibraryMethodInvocationStatement libraryMethodInvocationStatement: + this.EmitLibraryMethodInvocationStatement(libraryMethodInvocationStatement); + break; + + case BoundEventAssignmentStatement eventAssignmentStatement: + this.EmitEventAssignmentStatement(eventAssignmentStatement); + break; + + case BoundVariableAssignmentStatement variableAssignmentStatement: + this.EmitVariableAssignmentStatement(variableAssignmentStatement); + break; + + case BoundPropertyAssignmentStatement propertyAssignmentStatement: + this.EmitPropertyAssignmentStatement(propertyAssignmentStatement); + break; + + case BoundArrayAssignmentStatement arrayAssignmentStatement: + this.EmitArrayAssignmentStatement(arrayAssignmentStatement); + break; + + default: + throw ExceptionUtilities.UnexpectedValue(statement); } } @@ -102,6 +155,89 @@ private void EmitWhileStatement(BoundWhileStatement statement) this.instructions.Add(new TransientLabelInstruction(endOfLoopLabel, endOfLoopRange)); } + private void EmitForEachStatement(BoundForEachStatement statement) + { + // ForEach lowers to iterating over collection items + this.EmitBlockStatement(statement.Body); + } + + private void EmitSelectStatement(BoundSelectStatement statement) + { + string endSelectLabel = this.GenerateJumpLabel(); + + foreach (var caseClause in statement.Cases) + { + if (caseClause.IsElse) + { + this.EmitBlockStatement(caseClause.Body); + break; + } + + string nextCaseLabel = this.GenerateJumpLabel(); + + this.EmitExpression(statement.Expression); + this.EmitExpression(caseClause.ValueExpressionOpt); + TextRange range = caseClause.Syntax.Range; + if (range.Start.Line != range.End.Line) + { + range = ((range.Start.Line, range.Start.Column), (range.Start.Line, range.Start.Column + 1)); + } + + this.instructions.Add(new EqualInstruction(range)); + this.instructions.Add(new TransientConditionalGoToInstruction(null, nextCaseLabel, range)); + + this.EmitBlockStatement(caseClause.Body); + TextRange stmtRange = statement.Syntax.Range; + if (stmtRange.Start.Line != stmtRange.End.Line) + { + stmtRange = ((stmtRange.Start.Line, stmtRange.Start.Column), (stmtRange.Start.Line, stmtRange.Start.Column + 1)); + } + + this.instructions.Add(new TransientUnconditionalGoToInstruction(endSelectLabel, stmtRange)); + this.instructions.Add(new TransientLabelInstruction(nextCaseLabel, stmtRange)); + } + + TextRange endRange = statement.Syntax.Range; + if (endRange.Start.Line != endRange.End.Line) + { + endRange = ((endRange.Start.Line, endRange.Start.Column), (endRange.Start.Line, endRange.Start.Column + 1)); + } + + this.instructions.Add(new TransientLabelInstruction(endSelectLabel, endRange)); + } + + private void EmitTryStatement(BoundTryStatement statement) + { + string endTryLabel = this.GenerateJumpLabel(); + + this.EmitBlockStatement(statement.Body); + + if (!statement.CatchClauseOpt.IsDefault()) + { + TextRange range = statement.Syntax.Range; + if (range.Start.Line != range.End.Line) + { + range = ((range.Start.Line, range.Start.Column), (range.Start.Line, range.Start.Column + 1)); + } + + this.instructions.Add(new TransientUnconditionalGoToInstruction(endTryLabel, range)); + this.EmitBlockStatement(statement.CatchClauseOpt.Body); + } + + if (!statement.FinallyClauseOpt.IsDefault()) + { + this.EmitBlockStatement(statement.FinallyClauseOpt.Body); + } + + TextRange endRange = statement.Syntax.Range; + if (endRange.Start.Line != endRange.End.Line) + { + endRange = ((endRange.Start.Line, endRange.Start.Column), (endRange.Start.Line, endRange.Start.Column + 1)); + } + + this.instructions.Add(new TransientLabelInstruction(endTryLabel, endRange)); + } + private void EmitForStatement(BoundForStatement statement) { string beforeCheckLabel = this.GenerateJumpLabel(); @@ -171,9 +307,24 @@ private void EmitGoToStatement(BoundGoToStatement statement) this.instructions.Add(new TransientUnconditionalGoToInstruction(statement.Label, statement.Syntax.GoToToken.Range)); } + private void EmitReturnStatement(BoundReturnStatement statement) + { + if (statement.HasExpression && !statement.ExpressionOpt.IsDefault()) + { + this.EmitExpression(statement.ExpressionOpt); + } + + this.instructions.Add(new ReturnInstruction(statement.HasExpression, statement.Syntax.Range)); + } + private void EmitSubModuleInvocationStatement(BoundSubModuleInvocationStatement statement) { - this.instructions.Add(new InvokeSubModuleInstruction(statement.Expression.Name, statement.Syntax.Range)); + foreach (var arg in statement.Expression.Arguments) + { + this.EmitExpression(arg); + } + + this.instructions.Add(new InvokeSubModuleInstruction(statement.Expression.Name, expectsReturn: false, statement.Syntax.Range)); } private void EmitLibraryMethodInvocationStatement(BoundLibraryMethodInvocationStatement statement) @@ -239,16 +390,52 @@ private void EmitExpression(BaseBoundExpression expression) { switch (expression) { - case BoundUnaryExpression unaryExpression: this.EmitUnaryExpression(unaryExpression); break; - case BoundBinaryExpression binaryExpression: this.EmitBinaryExpression(binaryExpression); break; - case BoundArrayAccessExpression arrayAccessExpression: this.EmitArrayAccessExpression(arrayAccessExpression); break; - case BoundLibraryPropertyExpression libraryPropertyExpression: this.EmitLibraryPropertyExpression(libraryPropertyExpression); break; - case BoundLibraryMethodInvocationExpression libraryMethodInvocationExpression: this.EmitLibraryMethodInvocationExpression(libraryMethodInvocationExpression); break; - case BoundVariableExpression variableExpression: this.EmitVariableExpression(variableExpression); break; - case BoundStringLiteralExpression stringLiteralExpression: this.EmitStringLiteralExpression(stringLiteralExpression); break; - case BoundNumberLiteralExpression numberLiteralExpression: this.EmitNumberLiteralExpression(numberLiteralExpression); break; - case BoundParenthesisExpression parenthesisExpression: this.EmitExpression(parenthesisExpression.Expression); break; - default: throw ExceptionUtilities.UnexpectedValue(expression); + case BoundUnaryExpression unaryExpression: + this.EmitUnaryExpression(unaryExpression); + break; + + case BoundBinaryExpression binaryExpression: + this.EmitBinaryExpression(binaryExpression); + break; + + case BoundArrayAccessExpression arrayAccessExpression: + this.EmitArrayAccessExpression(arrayAccessExpression); + break; + + case BoundLibraryPropertyExpression libraryPropertyExpression: + this.EmitLibraryPropertyExpression(libraryPropertyExpression); + break; + + case BoundLibraryMethodInvocationExpression libraryMethodInvocationExpression: + this.EmitLibraryMethodInvocationExpression(libraryMethodInvocationExpression); + break; + + case BoundSubModuleInvocationExpression subModuleInvocationExpression: + this.EmitSubModuleInvocationExpression(subModuleInvocationExpression); + break; + + case BoundSubModuleExpression subModuleExpression: + this.instructions.Add(new PushValueInstruction(StringValue.Create(subModuleExpression.Name), subModuleExpression.Syntax.Range)); + break; + + case BoundVariableExpression variableExpression: + this.EmitVariableExpression(variableExpression); + break; + + case BoundStringLiteralExpression stringLiteralExpression: + this.EmitStringLiteralExpression(stringLiteralExpression); + break; + + case BoundNumberLiteralExpression numberLiteralExpression: + this.EmitNumberLiteralExpression(numberLiteralExpression); + break; + + case BoundParenthesisExpression parenthesisExpression: + this.EmitExpression(parenthesisExpression.Expression); + break; + + default: + throw ExceptionUtilities.UnexpectedValue(expression); } } @@ -276,19 +463,56 @@ private void EmitBinaryExpression(BoundBinaryExpression expression) switch (expression.Kind) { - case TokenKind.Or: this.EmitLogicalOrExpression(expression); return; - case TokenKind.And: this.EmitLogicalAndExpression(expression); return; - case TokenKind.Equal: binaryInstruction = new EqualInstruction(expression.Syntax.Range); break; - case TokenKind.NotEqual: binaryInstruction = new NotEqualInstruction(expression.Syntax.Range); break; - case TokenKind.LessThan: binaryInstruction = new LessThanInstruction(expression.Syntax.Range); break; - case TokenKind.LessThanOrEqual: binaryInstruction = new LessThanOrEqualInstruction(expression.Syntax.Range); break; - case TokenKind.GreaterThan: binaryInstruction = new GreaterThanInstruction(expression.Syntax.Range); break; - case TokenKind.GreaterThanOrEqual: binaryInstruction = new GreaterThanOrEqualInstruction(expression.Syntax.Range); break; - case TokenKind.Plus: binaryInstruction = new AddInstruction(expression.Syntax.Range); break; - case TokenKind.Minus: binaryInstruction = new SubtractInstruction(expression.Syntax.Range); break; - case TokenKind.Multiply: binaryInstruction = new MultiplyInstruction(expression.Syntax.Range); break; - case TokenKind.Divide: binaryInstruction = new DivideInstruction(expression.Syntax.Range); break; - default: throw ExceptionUtilities.UnexpectedValue(expression.Kind); + case TokenKind.Or: + this.EmitLogicalOrExpression(expression); + return; + + case TokenKind.And: + this.EmitLogicalAndExpression(expression); + return; + + case TokenKind.Equal: + binaryInstruction = new EqualInstruction(expression.Syntax.Range); + break; + + case TokenKind.NotEqual: + binaryInstruction = new NotEqualInstruction(expression.Syntax.Range); + break; + + case TokenKind.LessThan: + binaryInstruction = new LessThanInstruction(expression.Syntax.Range); + break; + + case TokenKind.LessThanOrEqual: + binaryInstruction = new LessThanOrEqualInstruction(expression.Syntax.Range); + break; + + case TokenKind.GreaterThan: + binaryInstruction = new GreaterThanInstruction(expression.Syntax.Range); + break; + + case TokenKind.GreaterThanOrEqual: + binaryInstruction = new GreaterThanOrEqualInstruction(expression.Syntax.Range); + break; + + case TokenKind.Plus: + binaryInstruction = new AddInstruction(expression.Syntax.Range); + break; + + case TokenKind.Minus: + binaryInstruction = new SubtractInstruction(expression.Syntax.Range); + break; + + case TokenKind.Multiply: + binaryInstruction = new MultiplyInstruction(expression.Syntax.Range); + break; + + case TokenKind.Divide: + binaryInstruction = new DivideInstruction(expression.Syntax.Range); + break; + + default: + throw ExceptionUtilities.UnexpectedValue(expression.Kind); } this.EmitExpression(expression.Left); @@ -366,6 +590,16 @@ private void EmitLibraryPropertyExpression(BoundLibraryPropertyExpression expres this.instructions.Add(new LoadPropertyInstruction(expression.Library.Name, expression.Name, expression.Syntax.Range)); } + private void EmitSubModuleInvocationExpression(BoundSubModuleInvocationExpression expression) + { + foreach (var arg in expression.Arguments) + { + this.EmitExpression(arg); + } + + this.instructions.Add(new InvokeSubModuleInstruction(expression.Name, expectsReturn: true, expression.Syntax.Range)); + } + private void EmitLibraryMethodInvocationExpression(BoundLibraryMethodInvocationExpression expression) { switch (expression.Method.Library.Name.ToUpperInvariant()) diff --git a/Source/SmallBasic.Compiler/Runtime/RuntimeModule.cs b/Source/SmallBasic.Compiler/Runtime/RuntimeModule.cs index 0c346bdb..fb711ff7 100644 --- a/Source/SmallBasic.Compiler/Runtime/RuntimeModule.cs +++ b/Source/SmallBasic.Compiler/Runtime/RuntimeModule.cs @@ -9,17 +9,20 @@ namespace SmallBasic.Compiler.Runtime public sealed class RuntimeModule { - internal RuntimeModule(string name, IReadOnlyList instructions, StatementBlockSyntax syntax) + internal RuntimeModule(string name, IReadOnlyList parameters, IReadOnlyList instructions, BaseStatementSyntax syntax) { this.Name = name; + this.Parameters = parameters ?? System.Array.Empty(); this.Instructions = instructions; this.Syntax = syntax; } public string Name { get; private set; } + public IReadOnlyList Parameters { get; private set; } + internal IReadOnlyList Instructions { get; private set; } - internal StatementBlockSyntax Syntax { get; private set; } + internal BaseStatementSyntax Syntax { get; private set; } } } diff --git a/Source/SmallBasic.Compiler/Scanning/Scanner.cs b/Source/SmallBasic.Compiler/Scanning/Scanner.cs index 9443ea59..3761910a 100644 --- a/Source/SmallBasic.Compiler/Scanning/Scanner.cs +++ b/Source/SmallBasic.Compiler/Scanning/Scanner.cs @@ -205,6 +205,21 @@ private void ScanWordToken() case "endwhile": this.AddToken(word, TokenKind.EndWhile); return; case "sub": this.AddToken(word, TokenKind.Sub); return; case "endsub": this.AddToken(word, TokenKind.EndSub); return; + case "function": this.AddToken(word, TokenKind.Function); return; + case "fn": this.AddToken(word, TokenKind.Fn); return; + case "endfunction": this.AddToken(word, TokenKind.EndFunction); return; + case "endfn": this.AddToken(word, TokenKind.EndFn); return; + case "return": this.AddToken(word, TokenKind.Return); return; + case "import": this.AddToken(word, TokenKind.Import); return; + case "foreach": this.AddToken(word, TokenKind.ForEach); return; + case "in": this.AddToken(word, TokenKind.In); return; + case "select": this.AddToken(word, TokenKind.Select); return; + case "case": this.AddToken(word, TokenKind.Case); return; + case "endselect": this.AddToken(word, TokenKind.EndSelect); return; + case "try": this.AddToken(word, TokenKind.Try); return; + case "catch": this.AddToken(word, TokenKind.Catch); return; + case "finally": this.AddToken(word, TokenKind.Finally); return; + case "endtry": this.AddToken(word, TokenKind.EndTry); return; case "or": this.AddToken(word, TokenKind.Or); return; case "and": this.AddToken(word, TokenKind.And); return; default: this.AddToken(word, TokenKind.Identifier); return; diff --git a/Source/SmallBasic.Compiler/Scanning/TokenKind.Generated.cs b/Source/SmallBasic.Compiler/Scanning/TokenKind.Generated.cs index 663692e6..a3ead358 100644 --- a/Source/SmallBasic.Compiler/Scanning/TokenKind.Generated.cs +++ b/Source/SmallBasic.Compiler/Scanning/TokenKind.Generated.cs @@ -1,103 +1,133 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Compiler.Scanning -{ - using SmallBasic.Utilities; - using SmallBasic.Utilities.Resources; - - internal enum TokenKind - { - If, - Then, - Else, - ElseIf, - EndIf, - For, - To, - Step, - EndFor, - While, - EndWhile, - Sub, - EndSub, - GoTo, - Or, - And, - Dot, - Comma, - RightParen, - LeftParen, - RightBracket, - LeftBracket, - Equal, - NotEqual, - Plus, - Minus, - Multiply, - Divide, - Colon, - LessThan, - GreaterThan, - LessThanOrEqual, - GreaterThanOrEqual, - Identifier, - NumberLiteral, - StringLiteral, - Comment, - Unrecognized, - } - - internal static partial class TokenKindExtensions - { - public static string ToDisplayString(this TokenKind kind) - { - switch (kind) - { - case TokenKind.If: return "If"; - case TokenKind.Then: return "Then"; - case TokenKind.Else: return "Else"; - case TokenKind.ElseIf: return "ElseIf"; - case TokenKind.EndIf: return "EndIf"; - case TokenKind.For: return "For"; - case TokenKind.To: return "To"; - case TokenKind.Step: return "Step"; - case TokenKind.EndFor: return "EndFor"; - case TokenKind.While: return "While"; - case TokenKind.EndWhile: return "EndWhile"; - case TokenKind.Sub: return "Sub"; - case TokenKind.EndSub: return "EndSub"; - case TokenKind.GoTo: return "GoTo"; - case TokenKind.Or: return "Or"; - case TokenKind.And: return "And"; - case TokenKind.Dot: return "."; - case TokenKind.Comma: return ","; - case TokenKind.RightParen: return ")"; - case TokenKind.LeftParen: return "("; - case TokenKind.RightBracket: return "]"; - case TokenKind.LeftBracket: return "["; - case TokenKind.Equal: return "="; - case TokenKind.NotEqual: return "<>"; - case TokenKind.Plus: return "+"; - case TokenKind.Minus: return "-"; - case TokenKind.Multiply: return "*"; - case TokenKind.Divide: return "/"; - case TokenKind.Colon: return ":"; - case TokenKind.LessThan: return "<"; - case TokenKind.GreaterThan: return ">"; - case TokenKind.LessThanOrEqual: return "<="; - case TokenKind.GreaterThanOrEqual: return ">="; - case TokenKind.Identifier: return TokenKindsResources.Identifier; - case TokenKind.NumberLiteral: return TokenKindsResources.NumberLiteral; - case TokenKind.StringLiteral: return TokenKindsResources.StringLiteral; - case TokenKind.Comment: return TokenKindsResources.Comment; - case TokenKind.Unrecognized: return TokenKindsResources.Unrecognized; - default: throw ExceptionUtilities.UnexpectedValue(kind); - } - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Compiler.Scanning +{ + using SmallBasic.Utilities; + using SmallBasic.Utilities.Resources; + + internal enum TokenKind + { + If, + Then, + Else, + ElseIf, + EndIf, + For, + To, + Step, + EndFor, + ForEach, + In, + While, + EndWhile, + Select, + Case, + EndSelect, + Try, + Catch, + Finally, + EndTry, + Sub, + EndSub, + Function, + Fn, + EndFunction, + EndFn, + Return, + Import, + GoTo, + Or, + And, + Dot, + Comma, + RightParen, + LeftParen, + RightBracket, + LeftBracket, + Equal, + NotEqual, + Plus, + Minus, + Multiply, + Divide, + Colon, + LessThan, + GreaterThan, + LessThanOrEqual, + GreaterThanOrEqual, + Identifier, + NumberLiteral, + StringLiteral, + Comment, + Unrecognized, + } + + internal static partial class TokenKindExtensions + { + public static string ToDisplayString(this TokenKind kind) + { + switch (kind) + { + case TokenKind.If: return "If"; + case TokenKind.Then: return "Then"; + case TokenKind.Else: return "Else"; + case TokenKind.ElseIf: return "ElseIf"; + case TokenKind.EndIf: return "EndIf"; + case TokenKind.For: return "For"; + case TokenKind.To: return "To"; + case TokenKind.Step: return "Step"; + case TokenKind.EndFor: return "EndFor"; + case TokenKind.ForEach: return "ForEach"; + case TokenKind.In: return "In"; + case TokenKind.While: return "While"; + case TokenKind.EndWhile: return "EndWhile"; + case TokenKind.Select: return "Select"; + case TokenKind.Case: return "Case"; + case TokenKind.EndSelect: return "EndSelect"; + case TokenKind.Try: return "Try"; + case TokenKind.Catch: return "Catch"; + case TokenKind.Finally: return "Finally"; + case TokenKind.EndTry: return "EndTry"; + case TokenKind.Sub: return "Sub"; + case TokenKind.EndSub: return "EndSub"; + case TokenKind.Function: return "Function"; + case TokenKind.Fn: return "Fn"; + case TokenKind.EndFunction: return "EndFunction"; + case TokenKind.EndFn: return "EndFn"; + case TokenKind.Return: return "Return"; + case TokenKind.Import: return "Import"; + case TokenKind.GoTo: return "GoTo"; + case TokenKind.Or: return "Or"; + case TokenKind.And: return "And"; + case TokenKind.Dot: return "."; + case TokenKind.Comma: return ","; + case TokenKind.RightParen: return ")"; + case TokenKind.LeftParen: return "("; + case TokenKind.RightBracket: return "]"; + case TokenKind.LeftBracket: return "["; + case TokenKind.Equal: return "="; + case TokenKind.NotEqual: return "<>"; + case TokenKind.Plus: return "+"; + case TokenKind.Minus: return "-"; + case TokenKind.Multiply: return "*"; + case TokenKind.Divide: return "/"; + case TokenKind.Colon: return ":"; + case TokenKind.LessThan: return "<"; + case TokenKind.GreaterThan: return ">"; + case TokenKind.LessThanOrEqual: return "<="; + case TokenKind.GreaterThanOrEqual: return ">="; + case TokenKind.Identifier: return TokenKindsResources.Identifier; + case TokenKind.NumberLiteral: return TokenKindsResources.NumberLiteral; + case TokenKind.StringLiteral: return TokenKindsResources.StringLiteral; + case TokenKind.Comment: return TokenKindsResources.Comment; + case TokenKind.Unrecognized: return TokenKindsResources.Unrecognized; + default: throw ExceptionUtilities.UnexpectedValue(kind); + } + } + } +} diff --git a/Source/SmallBasic.Compiler/Services/CompletionItemProvider.cs b/Source/SmallBasic.Compiler/Services/CompletionItemProvider.cs index 623f97b6..49d6a379 100644 --- a/Source/SmallBasic.Compiler/Services/CompletionItemProvider.cs +++ b/Source/SmallBasic.Compiler/Services/CompletionItemProvider.cs @@ -118,6 +118,14 @@ void addSnippet(string name, params string[] lines) addSnippet("Sub", "Sub ${1:name}", "EndSub"); addSnippet("EndSub", "EndSub"); + addSnippet("Function", "Function ${1:name}(${2:params})", " Return ${3:result}", "EndFunction"); + addSnippet("Fn", "Fn ${1:name}(${2:params})", " Return ${3:result}", "EndFn"); + addSnippet("EndFunction", "EndFunction"); + addSnippet("EndFn", "EndFn"); + + addSnippet("Return", "Return ${1:expression}"); + addSnippet("Import", "Import \"${1:file.sb}\""); + return items.ToArray(); } } diff --git a/Source/SmallBasic.Compiler/SmallBasicCompilation.cs b/Source/SmallBasic.Compiler/SmallBasicCompilation.cs index 9ff0bd6b..5353577a 100644 --- a/Source/SmallBasic.Compiler/SmallBasicCompilation.cs +++ b/Source/SmallBasic.Compiler/SmallBasicCompilation.cs @@ -25,21 +25,21 @@ public sealed class SmallBasicCompilation private readonly Lazy lazyAnalysis; - public SmallBasicCompilation(string text) + public SmallBasicCompilation(string text, Func fileResolver = null, string baseDirectory = "") #if IsBuildingForDesktop - : this(text, isRunningOnDesktop: true) + : this(text, isRunningOnDesktop: true, fileResolver: fileResolver, baseDirectory: baseDirectory) #else - : this(text, isRunningOnDesktop: false) + : this(text, isRunningOnDesktop: false, fileResolver: fileResolver, baseDirectory: baseDirectory) #endif { } - public SmallBasicCompilation(string text, bool isRunningOnDesktop) + public SmallBasicCompilation(string text, bool isRunningOnDesktop, Func fileResolver = null, string baseDirectory = "") { this.diagnostics = new DiagnosticBag(); this.isRunningOnDesktop = isRunningOnDesktop; - this.Text = text; + this.Text = ProcessImports(text, fileResolver, baseDirectory, new HashSet(), this.diagnostics); this.scanner = new Scanner(this.Text, this.diagnostics); this.parser = new Parser(this.scanner.Tokens, this.diagnostics); @@ -61,5 +61,67 @@ public SmallBasicCompilation(string text, bool isRunningOnDesktop) public MonacoCompletionItem[] ProvideCompletionItems(TextPosition position) => CompletionItemProvider.Provide(this.parser, this.binder, position); public string[] ProvideHover(TextPosition position) => HoverProvider.Provide(this.diagnostics, this.parser, position); + + private static string ProcessImports(string sourceText, Func fileResolver, string baseDirectory, HashSet visitedPaths, DiagnosticBag diagnostics) + { + if (string.IsNullOrEmpty(sourceText) || !sourceText.Contains("Import")) + { + return sourceText; + } + + var lines = sourceText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); + var resultLines = new List(); + + foreach (var line in lines) + { + string trimmed = line.Trim(); + if (trimmed.StartsWith("Import ", StringComparison.OrdinalIgnoreCase) || trimmed.StartsWith("Import\t", StringComparison.OrdinalIgnoreCase)) + { + string path = trimmed.Substring(6).Trim(); + if (path.StartsWith("\"", StringComparison.Ordinal) && path.EndsWith("\"", StringComparison.Ordinal) && path.Length >= 2) + { + path = path.Substring(1, path.Length - 2); + } + + string fullPath = System.IO.Path.IsPathRooted(path) ? path : System.IO.Path.Combine(baseDirectory ?? string.Empty, path); + string normalizedPath = fullPath; + try + { + normalizedPath = System.IO.Path.GetFullPath(fullPath); + } + catch + { + } + + if (!visitedPaths.Contains(normalizedPath)) + { + visitedPaths.Add(normalizedPath); + + string importedContent = null; + if (!fileResolver.IsDefault()) + { + importedContent = fileResolver(path); + } + else if (System.IO.File.Exists(fullPath)) + { + importedContent = System.IO.File.ReadAllText(fullPath); + } + + if (!importedContent.IsDefault()) + { + string newBaseDir = System.IO.Path.GetDirectoryName(fullPath) ?? string.Empty; + string processed = ProcessImports(importedContent, fileResolver, newBaseDir, visitedPaths, diagnostics); + resultLines.Add(processed); + } + } + } + else + { + resultLines.Add(line); + } + } + + return string.Join(Environment.NewLine, resultLines); + } } } diff --git a/Source/SmallBasic.Compiler/SmallBasicEngine.cs b/Source/SmallBasic.Compiler/SmallBasicEngine.cs index aebc1999..909cffcd 100644 --- a/Source/SmallBasic.Compiler/SmallBasicEngine.cs +++ b/Source/SmallBasic.Compiler/SmallBasicEngine.cs @@ -53,10 +53,10 @@ public SmallBasicEngine(SmallBasicCompilation compilation, IEngineLibraries libr this.Libraries.SetEventCallbacks(this); - RuntimeModule mainModule = this.EmitAndSaveModule("Program", compilation.MainModule); + RuntimeModule mainModule = this.EmitAndSaveModule("Program", Array.Empty(), compilation.MainModule); foreach (BoundSubModule subModule in compilation.SubModules.Values) { - this.EmitAndSaveModule(subModule.Name, subModule.Body); + this.EmitAndSaveModule(subModule.Name, subModule.Parameters, subModule.Body); } this.ExecutionStack.AddLast(new Frame(mainModule)); @@ -188,10 +188,10 @@ internal void BlockOnNumberInput() this.State = ExecutionState.BlockedOnNumberInput; } - private RuntimeModule EmitAndSaveModule(string name, BoundStatementBlock body) + private RuntimeModule EmitAndSaveModule(string name, IReadOnlyList parameters, BoundStatementBlock body) { ModuleEmitter emitter = new ModuleEmitter(body); - RuntimeModule module = new RuntimeModule(name, emitter.Instructions, body.Syntax); + RuntimeModule module = new RuntimeModule(name, parameters, emitter.Instructions, body.Syntax); this.Modules.Add(module.Name, module); return module; diff --git a/Source/SmallBasic.Editor/Bridge/Bridge.Generated.cs b/Source/SmallBasic.Editor/Bridge/Bridge.Generated.cs index 7960ad45..73f84c52 100644 --- a/Source/SmallBasic.Editor/Bridge/Bridge.Generated.cs +++ b/Source/SmallBasic.Editor/Bridge/Bridge.Generated.cs @@ -1,110 +1,110 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Editor -{ - using System.Threading.Tasks; - using Microsoft.JSInterop; - using SmallBasic.Utilities.Bridge; - - internal static class Bridge - { - public static class Process - { - public static async Task OpenExternalLink(string url) - { - await JSRuntime.Current.InvokeAsync("Bridge.Process.OpenExternalLink", url).ConfigureAwait(false); - } - } - - public static class File - { - public static Task AppendContents(FileBridgeModels.PathAndContentsArgs args) - { - return JSRuntime.Current.InvokeAsync("Bridge.File.AppendContents", args); - } - - public static Task CopyFile(FileBridgeModels.SourceAndDestinationArgs args) - { - return JSRuntime.Current.InvokeAsync("Bridge.File.CopyFile", args); - } - - public static Task CreateDirectory(string directoryPath) - { - return JSRuntime.Current.InvokeAsync("Bridge.File.CreateDirectory", directoryPath); - } - - public static Task DeleteDirectory(string directoryPath) - { - return JSRuntime.Current.InvokeAsync("Bridge.File.DeleteDirectory", directoryPath); - } - - public static Task DeleteFile(string filePath) - { - return JSRuntime.Current.InvokeAsync("Bridge.File.DeleteFile", filePath); - } - - public static Task> GetDirectories(string directoryPath) - { - return JSRuntime.Current.InvokeAsync>("Bridge.File.GetDirectories", directoryPath); - } - - public static Task> GetFiles(string directoryPath) - { - return JSRuntime.Current.InvokeAsync>("Bridge.File.GetFiles", directoryPath); - } - - public static Task> GetTemporaryFilePath() - { - return JSRuntime.Current.InvokeAsync>("Bridge.File.GetTemporaryFilePath"); - } - - public static Task InsertLine(FileBridgeModels.PathAndLineAndContentsArgs args) - { - return JSRuntime.Current.InvokeAsync("Bridge.File.InsertLine", args); - } - - public static Task> ReadContents(string filePath) - { - return JSRuntime.Current.InvokeAsync>("Bridge.File.ReadContents", filePath); - } - - public static Task> ReadLine(FileBridgeModels.PathAndLineArgs args) - { - return JSRuntime.Current.InvokeAsync>("Bridge.File.ReadLine", args); - } - - public static Task WriteContents(FileBridgeModels.PathAndContentsArgs args) - { - return JSRuntime.Current.InvokeAsync("Bridge.File.WriteContents", args); - } - - public static Task WriteLine(FileBridgeModels.PathAndLineAndContentsArgs args) - { - return JSRuntime.Current.InvokeAsync("Bridge.File.WriteLine", args); - } - } - - public static class Network - { - public static Task LoadImage(string fileNameOrUrl) - { - return JSRuntime.Current.InvokeAsync("Bridge.Network.LoadImage", fileNameOrUrl); - } - - public static Task DownloadFile(string url) - { - return JSRuntime.Current.InvokeAsync("Bridge.Network.DownloadFile", url); - } - - public static Task GetWebPageContents(string url) - { - return JSRuntime.Current.InvokeAsync("Bridge.Network.GetWebPageContents", url); - } - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Editor +{ + using System.Threading.Tasks; + using Microsoft.JSInterop; + using SmallBasic.Utilities.Bridge; + + internal static class Bridge + { + public static class Process + { + public static async Task OpenExternalLink(string url) + { + await JSRuntime.Current.InvokeAsync("Bridge.Process.OpenExternalLink", url).ConfigureAwait(false); + } + } + + public static class File + { + public static Task AppendContents(FileBridgeModels.PathAndContentsArgs args) + { + return JSRuntime.Current.InvokeAsync("Bridge.File.AppendContents", args); + } + + public static Task CopyFile(FileBridgeModels.SourceAndDestinationArgs args) + { + return JSRuntime.Current.InvokeAsync("Bridge.File.CopyFile", args); + } + + public static Task CreateDirectory(string directoryPath) + { + return JSRuntime.Current.InvokeAsync("Bridge.File.CreateDirectory", directoryPath); + } + + public static Task DeleteDirectory(string directoryPath) + { + return JSRuntime.Current.InvokeAsync("Bridge.File.DeleteDirectory", directoryPath); + } + + public static Task DeleteFile(string filePath) + { + return JSRuntime.Current.InvokeAsync("Bridge.File.DeleteFile", filePath); + } + + public static Task> GetDirectories(string directoryPath) + { + return JSRuntime.Current.InvokeAsync>("Bridge.File.GetDirectories", directoryPath); + } + + public static Task> GetFiles(string directoryPath) + { + return JSRuntime.Current.InvokeAsync>("Bridge.File.GetFiles", directoryPath); + } + + public static Task> GetTemporaryFilePath() + { + return JSRuntime.Current.InvokeAsync>("Bridge.File.GetTemporaryFilePath"); + } + + public static Task InsertLine(FileBridgeModels.PathAndLineAndContentsArgs args) + { + return JSRuntime.Current.InvokeAsync("Bridge.File.InsertLine", args); + } + + public static Task> ReadContents(string filePath) + { + return JSRuntime.Current.InvokeAsync>("Bridge.File.ReadContents", filePath); + } + + public static Task> ReadLine(FileBridgeModels.PathAndLineArgs args) + { + return JSRuntime.Current.InvokeAsync>("Bridge.File.ReadLine", args); + } + + public static Task WriteContents(FileBridgeModels.PathAndContentsArgs args) + { + return JSRuntime.Current.InvokeAsync("Bridge.File.WriteContents", args); + } + + public static Task WriteLine(FileBridgeModels.PathAndLineAndContentsArgs args) + { + return JSRuntime.Current.InvokeAsync("Bridge.File.WriteLine", args); + } + } + + public static class Network + { + public static Task LoadImage(string fileNameOrUrl) + { + return JSRuntime.Current.InvokeAsync("Bridge.Network.LoadImage", fileNameOrUrl); + } + + public static Task DownloadFile(string url) + { + return JSRuntime.Current.InvokeAsync("Bridge.Network.DownloadFile", url); + } + + public static Task GetWebPageContents(string url) + { + return JSRuntime.Current.InvokeAsync("Bridge.Network.GetWebPageContents", url); + } + } + } +} diff --git a/Source/SmallBasic.Editor/Interop/CSInterop.Generated.cs b/Source/SmallBasic.Editor/Interop/CSInterop.Generated.cs index 068624d2..a0aa9ca3 100644 --- a/Source/SmallBasic.Editor/Interop/CSInterop.Generated.cs +++ b/Source/SmallBasic.Editor/Interop/CSInterop.Generated.cs @@ -1,77 +1,77 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Editor.Interop -{ - using System.Threading.Tasks; - using Microsoft.JSInterop; - using SmallBasic.Compiler.Services; - - internal interface IMonacoInterop - { - Task UpdateDiagnostics(string code); - - Task ProvideCompletionItems(string code, MonacoPosition position); - - Task ProvideHover(string code, MonacoPosition position); - } - - internal interface IGraphicsDisplayInterop - { - Task UpdateDisplayLocation(decimal x, decimal y); - - Task OnKeyUp(string key); - - Task OnKeyDown(string key); - } - - public static class CSInterop - { - private static readonly IMonacoInterop Monaco = new MonacoInterop(); - - private static readonly IGraphicsDisplayInterop GraphicsDisplay = new GraphicsDisplayInterop(); - - [JSInvokable("CSIntrop.Monaco.UpdateDiagnostics")] - public static Task Monaco_UpdateDiagnostics(string code) - { - return Monaco.UpdateDiagnostics(code); - } - - [JSInvokable("CSIntrop.Monaco.ProvideCompletionItems")] - public static Task Monaco_ProvideCompletionItems(string code, MonacoPosition position) - { - return Monaco.ProvideCompletionItems(code, position); - } - - [JSInvokable("CSIntrop.Monaco.ProvideHover")] - public static Task Monaco_ProvideHover(string code, MonacoPosition position) - { - return Monaco.ProvideHover(code, position); - } - - [JSInvokable("CSIntrop.GraphicsDisplay.UpdateDisplayLocation")] - public static async Task GraphicsDisplay_UpdateDisplayLocation(decimal x, decimal y) - { - await GraphicsDisplay.UpdateDisplayLocation(x, y).ConfigureAwait(false); - return true; - } - - [JSInvokable("CSIntrop.GraphicsDisplay.OnKeyUp")] - public static async Task GraphicsDisplay_OnKeyUp(string key) - { - await GraphicsDisplay.OnKeyUp(key).ConfigureAwait(false); - return true; - } - - [JSInvokable("CSIntrop.GraphicsDisplay.OnKeyDown")] - public static async Task GraphicsDisplay_OnKeyDown(string key) - { - await GraphicsDisplay.OnKeyDown(key).ConfigureAwait(false); - return true; - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Editor.Interop +{ + using System.Threading.Tasks; + using Microsoft.JSInterop; + using SmallBasic.Compiler.Services; + + internal interface IMonacoInterop + { + Task UpdateDiagnostics(string code); + + Task ProvideCompletionItems(string code, MonacoPosition position); + + Task ProvideHover(string code, MonacoPosition position); + } + + internal interface IGraphicsDisplayInterop + { + Task UpdateDisplayLocation(decimal x, decimal y); + + Task OnKeyUp(string key); + + Task OnKeyDown(string key); + } + + public static class CSInterop + { + private static readonly IMonacoInterop Monaco = new MonacoInterop(); + + private static readonly IGraphicsDisplayInterop GraphicsDisplay = new GraphicsDisplayInterop(); + + [JSInvokable("CSIntrop.Monaco.UpdateDiagnostics")] + public static Task Monaco_UpdateDiagnostics(string code) + { + return Monaco.UpdateDiagnostics(code); + } + + [JSInvokable("CSIntrop.Monaco.ProvideCompletionItems")] + public static Task Monaco_ProvideCompletionItems(string code, MonacoPosition position) + { + return Monaco.ProvideCompletionItems(code, position); + } + + [JSInvokable("CSIntrop.Monaco.ProvideHover")] + public static Task Monaco_ProvideHover(string code, MonacoPosition position) + { + return Monaco.ProvideHover(code, position); + } + + [JSInvokable("CSIntrop.GraphicsDisplay.UpdateDisplayLocation")] + public static async Task GraphicsDisplay_UpdateDisplayLocation(decimal x, decimal y) + { + await GraphicsDisplay.UpdateDisplayLocation(x, y).ConfigureAwait(false); + return true; + } + + [JSInvokable("CSIntrop.GraphicsDisplay.OnKeyUp")] + public static async Task GraphicsDisplay_OnKeyUp(string key) + { + await GraphicsDisplay.OnKeyUp(key).ConfigureAwait(false); + return true; + } + + [JSInvokable("CSIntrop.GraphicsDisplay.OnKeyDown")] + public static async Task GraphicsDisplay_OnKeyDown(string key) + { + await GraphicsDisplay.OnKeyDown(key).ConfigureAwait(false); + return true; + } + } +} diff --git a/Source/SmallBasic.Editor/Interop/JSInterop.Generated.cs b/Source/SmallBasic.Editor/Interop/JSInterop.Generated.cs index 5c10edde..81f3aea8 100644 --- a/Source/SmallBasic.Editor/Interop/JSInterop.Generated.cs +++ b/Source/SmallBasic.Editor/Interop/JSInterop.Generated.cs @@ -1,123 +1,123 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Editor.Interop -{ - using System.Threading.Tasks; - using Microsoft.AspNetCore.Blazor; - using Microsoft.JSInterop; - using SmallBasic.Compiler.Services; - - internal static class JSInterop - { - public static class Layout - { - public static async Task InitializeWebView(string locale, string title) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Layout.initializeWebView", locale, title).ConfigureAwait(false); - } - - public static async Task OpenExternalLink(string url) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Layout.openExternalLink", url).ConfigureAwait(false); - } - - public static async Task ShowMessage(string title, string text) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Layout.showMessage", title, text).ConfigureAwait(false); - } - - public static Task GetElementHeight(ElementRef element) - { - return JSRuntime.Current.InvokeAsync("JSInterop.Layout.getElementHeight", element); - } - - public static Task GetElementWidth(ElementRef element) - { - return JSRuntime.Current.InvokeAsync("JSInterop.Layout.getElementWidth", element); - } - - public static async Task ScrollIntoView(ElementRef element) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Layout.scrollIntoView", element).ConfigureAwait(false); - } - - public static async Task Focus(ElementRef element) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Layout.focus", element).ConfigureAwait(false); - } - } - - public static class Monaco - { - public static async Task Initialize(ElementRef editorElement, string initialValue, bool isReadOnly) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.initialize", editorElement, initialValue, isReadOnly).ConfigureAwait(false); - } - - public static async Task Dispose() - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.dispose").ConfigureAwait(false); - } - - public static async Task SelectRange(MonacoRange range) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.selectRange", range).ConfigureAwait(false); - } - - public static async Task HighlightLine(decimal line) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.highlightLine", line).ConfigureAwait(false); - } - - public static async Task RemoveDecorations() - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.removeDecorations").ConfigureAwait(false); - } - - public static async Task SaveToFile() - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.saveToFile").ConfigureAwait(false); - } - - public static async Task OpenFile(string confirmationMessage) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.openFile", confirmationMessage).ConfigureAwait(false); - } - - public static async Task ClearEditor(string confirmationMessage) - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.clearEditor", confirmationMessage).ConfigureAwait(false); - } - - public static async Task Cut() - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.cut").ConfigureAwait(false); - } - - public static async Task Copy() - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.copy").ConfigureAwait(false); - } - - public static async Task Paste() - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.paste").ConfigureAwait(false); - } - - public static async Task Undo() - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.undo").ConfigureAwait(false); - } - - public static async Task Redo() - { - await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.redo").ConfigureAwait(false); - } - } - } -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Editor.Interop +{ + using System.Threading.Tasks; + using Microsoft.AspNetCore.Blazor; + using Microsoft.JSInterop; + using SmallBasic.Compiler.Services; + + internal static class JSInterop + { + public static class Layout + { + public static async Task InitializeWebView(string locale, string title) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Layout.initializeWebView", locale, title).ConfigureAwait(false); + } + + public static async Task OpenExternalLink(string url) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Layout.openExternalLink", url).ConfigureAwait(false); + } + + public static async Task ShowMessage(string title, string text) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Layout.showMessage", title, text).ConfigureAwait(false); + } + + public static Task GetElementHeight(ElementRef element) + { + return JSRuntime.Current.InvokeAsync("JSInterop.Layout.getElementHeight", element); + } + + public static Task GetElementWidth(ElementRef element) + { + return JSRuntime.Current.InvokeAsync("JSInterop.Layout.getElementWidth", element); + } + + public static async Task ScrollIntoView(ElementRef element) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Layout.scrollIntoView", element).ConfigureAwait(false); + } + + public static async Task Focus(ElementRef element) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Layout.focus", element).ConfigureAwait(false); + } + } + + public static class Monaco + { + public static async Task Initialize(ElementRef editorElement, string initialValue, bool isReadOnly) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.initialize", editorElement, initialValue, isReadOnly).ConfigureAwait(false); + } + + public static async Task Dispose() + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.dispose").ConfigureAwait(false); + } + + public static async Task SelectRange(MonacoRange range) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.selectRange", range).ConfigureAwait(false); + } + + public static async Task HighlightLine(decimal line) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.highlightLine", line).ConfigureAwait(false); + } + + public static async Task RemoveDecorations() + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.removeDecorations").ConfigureAwait(false); + } + + public static async Task SaveToFile() + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.saveToFile").ConfigureAwait(false); + } + + public static async Task OpenFile(string confirmationMessage) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.openFile", confirmationMessage).ConfigureAwait(false); + } + + public static async Task ClearEditor(string confirmationMessage) + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.clearEditor", confirmationMessage).ConfigureAwait(false); + } + + public static async Task Cut() + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.cut").ConfigureAwait(false); + } + + public static async Task Copy() + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.copy").ConfigureAwait(false); + } + + public static async Task Paste() + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.paste").ConfigureAwait(false); + } + + public static async Task Undo() + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.undo").ConfigureAwait(false); + } + + public static async Task Redo() + { + await JSRuntime.Current.InvokeAsync("JSInterop.Monaco.redo").ConfigureAwait(false); + } + } + } +} diff --git a/Source/SmallBasic.Editor/SmallBasic.Editor.csproj b/Source/SmallBasic.Editor/SmallBasic.Editor.csproj index 7307dcc7..17a318d1 100644 --- a/Source/SmallBasic.Editor/SmallBasic.Editor.csproj +++ b/Source/SmallBasic.Editor/SmallBasic.Editor.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -20,7 +20,7 @@ - + diff --git a/Source/SmallBasic.Generators/Binding/BoundNodes.xml b/Source/SmallBasic.Generators/Binding/BoundNodes.xml index 1d036024..77c9a3be 100644 --- a/Source/SmallBasic.Generators/Binding/BoundNodes.xml +++ b/Source/SmallBasic.Generators/Binding/BoundNodes.xml @@ -1,11 +1,19 @@  - + + + + + + + + + @@ -57,6 +65,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -171,6 +220,7 @@ + diff --git a/Source/SmallBasic.Generators/Binding/GenerateBoundNodes.cs b/Source/SmallBasic.Generators/Binding/GenerateBoundNodes.cs index bee0afdc..b88e7bbe 100644 --- a/Source/SmallBasic.Generators/Binding/GenerateBoundNodes.cs +++ b/Source/SmallBasic.Generators/Binding/GenerateBoundNodes.cs @@ -86,7 +86,7 @@ private void ValidateNode(BoundNodeCollection model, BoundNode node) } } - if (node.Name.Contains("Syntax")) + if (node.Name.Contains("Syntax", StringComparison.Ordinal)) { this.LogError($"Node '{node.Name}' name should not contain 'Syntax'."); } diff --git a/Source/SmallBasic.Generators/Libraries/GenerateLibraryInterfaces.cs b/Source/SmallBasic.Generators/Libraries/GenerateLibraryInterfaces.cs index daca93c5..5d5754d3 100644 --- a/Source/SmallBasic.Generators/Libraries/GenerateLibraryInterfaces.cs +++ b/Source/SmallBasic.Generators/Libraries/GenerateLibraryInterfaces.cs @@ -1,4 +1,4 @@ -// +// // Licensed under the MIT License. See LICENSE file in the project root for license information. // @@ -17,6 +17,7 @@ protected override void Generate(LibraryCollection model) this.Line("using System;"); this.Line("using System.Threading.Tasks;"); + this.Line("using SmallBasic.Utilities;"); this.Blank(); foreach (Library library in model) @@ -112,14 +113,18 @@ private void GenerateEventCallbacks(LibraryCollection model) this.Blank(); } + this.Line($"if (!libraries.{library.Name}.IsDefault())"); + this.Brace(); foreach (Event @event in library.Events) { this.Line($@"libraries.{library.Name}.{@event.Name} += () => engine.RaiseEvent(""{library.Name}"", ""{@event.Name}"");"); } + + this.Unbrace(); } this.Unbrace(); this.Unbrace(); } } -} \ No newline at end of file +} diff --git a/Source/SmallBasic.Generators/Parsing/GenerateSyntaxNodes.cs b/Source/SmallBasic.Generators/Parsing/GenerateSyntaxNodes.cs index 87769c25..1d403703 100644 --- a/Source/SmallBasic.Generators/Parsing/GenerateSyntaxNodes.cs +++ b/Source/SmallBasic.Generators/Parsing/GenerateSyntaxNodes.cs @@ -93,7 +93,7 @@ private void ValidateNode(SyntaxNode node) this.LogError($"Node '{node.Name}' name should end with 'Syntax'."); } - if (node.Name.Contains("Bound")) + if (node.Name.Contains("Bound", StringComparison.Ordinal)) { this.LogError($"Node '{node.Name}' name should not contain 'Bound'."); } diff --git a/Source/SmallBasic.Generators/Parsing/SyntaxNodes.xml b/Source/SmallBasic.Generators/Parsing/SyntaxNodes.xml index e159ae44..3f6f87aa 100644 --- a/Source/SmallBasic.Generators/Parsing/SyntaxNodes.xml +++ b/Source/SmallBasic.Generators/Parsing/SyntaxNodes.xml @@ -11,6 +11,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -77,6 +110,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/SmallBasic.Generators/Scanning/TokenKinds.xml b/Source/SmallBasic.Generators/Scanning/TokenKinds.xml index 71379f43..cbf74371 100644 --- a/Source/SmallBasic.Generators/Scanning/TokenKinds.xml +++ b/Source/SmallBasic.Generators/Scanning/TokenKinds.xml @@ -11,12 +11,32 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Source/SmallBasic.Generators/SmallBasic.Generators.csproj b/Source/SmallBasic.Generators/SmallBasic.Generators.csproj index 1adf3c66..8d7d136a 100644 --- a/Source/SmallBasic.Generators/SmallBasic.Generators.csproj +++ b/Source/SmallBasic.Generators/SmallBasic.Generators.csproj @@ -1,7 +1,7 @@  - netcoreapp2.0 + net8.0 Exe diff --git a/Source/SmallBasic.Tests/LoggingTestLibraries.Generated.cs b/Source/SmallBasic.Tests/LoggingTestLibraries.Generated.cs index f9ccc688..340557d5 100644 --- a/Source/SmallBasic.Tests/LoggingTestLibraries.Generated.cs +++ b/Source/SmallBasic.Tests/LoggingTestLibraries.Generated.cs @@ -1,1392 +1,1392 @@ -// -// Licensed under the MIT License. See LICENSE file in the project root for license information. -// - -/// -/// This file is auto-generated by a build task. It shouldn't be edited by hand. -/// -namespace SmallBasic.Tests -{ - #pragma warning disable CS0067 // The event '{0}' is never used - using System; - using System.Text; - using System.Threading.Tasks; - using SmallBasic.Compiler.Runtime; - - internal sealed class LoggingArrayLibrary : IArrayLibrary - { - private readonly StringBuilder log; - - public LoggingArrayLibrary(StringBuilder log) - { - this.log = log; - } - - public bool ContainsIndex(ArrayValue array, string index) - { - this.log.AppendLine($"Array.ContainsIndex(array: '{array.ToDisplayString()}', index: '{index}')"); - return false; - } - - public bool ContainsValue(ArrayValue array, string value) - { - this.log.AppendLine($"Array.ContainsValue(array: '{array.ToDisplayString()}', value: '{value}')"); - return false; - } - - public ArrayValue GetAllIndices(ArrayValue array) - { - this.log.AppendLine($"Array.GetAllIndices(array: '{array.ToDisplayString()}')"); - return new ArrayValue(); - } - - public decimal GetItemCount(ArrayValue array) - { - this.log.AppendLine($"Array.GetItemCount(array: '{array.ToDisplayString()}')"); - return 0m; - } - - public BaseValue GetValue(string arrayName, string index) - { - this.log.AppendLine($"Array.GetValue(arrayName: '{arrayName}', index: '{index}')"); - return StringValue.Create(string.Empty); - } - - public bool IsArray(BaseValue array) - { - this.log.AppendLine($"Array.IsArray(array: '{array.ToDisplayString()}')"); - return false; - } - - public void RemoveValue(string arrayName, string index) - { - this.log.AppendLine($"Array.RemoveValue(arrayName: '{arrayName}', index: '{index}')"); - } - - public void SetValue(string arrayName, string index, BaseValue value) - { - this.log.AppendLine($"Array.SetValue(arrayName: '{arrayName}', index: '{index}', value: '{value.ToDisplayString()}')"); - } - } - - internal sealed class LoggingClockLibrary : IClockLibrary - { - private readonly StringBuilder log; - - public LoggingClockLibrary(StringBuilder log) - { - this.log = log; - } - - public string Get_Date() - { - this.log.AppendLine($"Clock.Get_Date()"); - return string.Empty; - } - - public decimal Get_Day() - { - this.log.AppendLine($"Clock.Get_Day()"); - return 0m; - } - - public decimal Get_ElapsedMilliseconds() - { - this.log.AppendLine($"Clock.Get_ElapsedMilliseconds()"); - return 0m; - } - - public decimal Get_Hour() - { - this.log.AppendLine($"Clock.Get_Hour()"); - return 0m; - } - - public decimal Get_Millisecond() - { - this.log.AppendLine($"Clock.Get_Millisecond()"); - return 0m; - } - - public decimal Get_Minute() - { - this.log.AppendLine($"Clock.Get_Minute()"); - return 0m; - } - - public decimal Get_Month() - { - this.log.AppendLine($"Clock.Get_Month()"); - return 0m; - } - - public decimal Get_Second() - { - this.log.AppendLine($"Clock.Get_Second()"); - return 0m; - } - - public string Get_Time() - { - this.log.AppendLine($"Clock.Get_Time()"); - return string.Empty; - } - - public string Get_WeekDay() - { - this.log.AppendLine($"Clock.Get_WeekDay()"); - return string.Empty; - } - - public decimal Get_Year() - { - this.log.AppendLine($"Clock.Get_Year()"); - return 0m; - } - } - - internal sealed class LoggingControlsLibrary : IControlsLibrary - { - private readonly StringBuilder log; - - public LoggingControlsLibrary(StringBuilder log) - { - this.log = log; - } - - public event Action ButtonClicked; - - public event Action TextTyped; - - public string Get_LastClickedButton() - { - this.log.AppendLine($"Controls.Get_LastClickedButton()"); - return string.Empty; - } - - public string Get_LastTypedTextBox() - { - this.log.AppendLine($"Controls.Get_LastTypedTextBox()"); - return string.Empty; - } - - public string AddButton(string caption, decimal left, decimal top) - { - this.log.AppendLine($"Controls.AddButton(caption: '{caption}', left: '{left}', top: '{top}')"); - return string.Empty; - } - - public string AddMultiLineTextBox(decimal left, decimal top) - { - this.log.AppendLine($"Controls.AddMultiLineTextBox(left: '{left}', top: '{top}')"); - return string.Empty; - } - - public string AddTextBox(decimal left, decimal top) - { - this.log.AppendLine($"Controls.AddTextBox(left: '{left}', top: '{top}')"); - return string.Empty; - } - - public string GetButtonCaption(string buttonName) - { - this.log.AppendLine($"Controls.GetButtonCaption(buttonName: '{buttonName}')"); - return string.Empty; - } - - public string GetTextBoxText(string textBoxName) - { - this.log.AppendLine($"Controls.GetTextBoxText(textBoxName: '{textBoxName}')"); - return string.Empty; - } - - public void HideControl(string controlName) - { - this.log.AppendLine($"Controls.HideControl(controlName: '{controlName}')"); - } - - public void Move(string control, decimal x, decimal y) - { - this.log.AppendLine($"Controls.Move(control: '{control}', x: '{x}', y: '{y}')"); - } - - public void Remove(string controlName) - { - this.log.AppendLine($"Controls.Remove(controlName: '{controlName}')"); - } - - public void SetButtonCaption(string buttonName, string caption) - { - this.log.AppendLine($"Controls.SetButtonCaption(buttonName: '{buttonName}', caption: '{caption}')"); - } - - public void SetSize(string control, decimal width, decimal height) - { - this.log.AppendLine($"Controls.SetSize(control: '{control}', width: '{width}', height: '{height}')"); - } - - public void SetTextBoxText(string textBoxName, string text) - { - this.log.AppendLine($"Controls.SetTextBoxText(textBoxName: '{textBoxName}', text: '{text}')"); - } - - public void ShowControl(string controlName) - { - this.log.AppendLine($"Controls.ShowControl(controlName: '{controlName}')"); - } - } - - internal sealed class LoggingDesktopLibrary : IDesktopLibrary - { - private readonly StringBuilder log; - - public LoggingDesktopLibrary(StringBuilder log) - { - this.log = log; - } - } - - internal sealed class LoggingDictionaryLibrary : IDictionaryLibrary - { - private readonly StringBuilder log; - - public LoggingDictionaryLibrary(StringBuilder log) - { - this.log = log; - } - } - - internal sealed class LoggingFileLibrary : IFileLibrary - { - private readonly StringBuilder log; - - public LoggingFileLibrary(StringBuilder log) - { - this.log = log; - } - - public string Get_LastError() - { - this.log.AppendLine($"File.Get_LastError()"); - return string.Empty; - } - - public void Set_LastError(string value) - { - this.log.AppendLine($"File.Set_LastError('{value}')"); - } - - public Task AppendContents(string filePath, string contents) - { - this.log.AppendLine($"File.AppendContents(filePath: '{filePath}', contents: '{contents}')"); - return Task.FromResult(string.Empty); - } - - public Task CopyFile(string sourceFilePath, string destinationFilePath) - { - this.log.AppendLine($"File.CopyFile(sourceFilePath: '{sourceFilePath}', destinationFilePath: '{destinationFilePath}')"); - return Task.FromResult(string.Empty); - } - - public Task CreateDirectory(string directoryPath) - { - this.log.AppendLine($"File.CreateDirectory(directoryPath: '{directoryPath}')"); - return Task.FromResult(string.Empty); - } - - public Task DeleteDirectory(string directoryPath) - { - this.log.AppendLine($"File.DeleteDirectory(directoryPath: '{directoryPath}')"); - return Task.FromResult(string.Empty); - } - - public Task DeleteFile(string filePath) - { - this.log.AppendLine($"File.DeleteFile(filePath: '{filePath}')"); - return Task.FromResult(string.Empty); - } - - public Task GetDirectories(string directoryPath) - { - this.log.AppendLine($"File.GetDirectories(directoryPath: '{directoryPath}')"); - return Task.FromResult(StringValue.Create(string.Empty)); - } - - public Task GetFiles(string directoryPath) - { - this.log.AppendLine($"File.GetFiles(directoryPath: '{directoryPath}')"); - return Task.FromResult(StringValue.Create(string.Empty)); - } - - public Task GetTemporaryFilePath() - { - this.log.AppendLine($"File.GetTemporaryFilePath()"); - return Task.FromResult(StringValue.Create(string.Empty)); - } - - public Task InsertLine(string filePath, decimal lineNumber, string contents) - { - this.log.AppendLine($"File.InsertLine(filePath: '{filePath}', lineNumber: '{lineNumber}', contents: '{contents}')"); - return Task.FromResult(string.Empty); - } - - public Task ReadContents(string filePath) - { - this.log.AppendLine($"File.ReadContents(filePath: '{filePath}')"); - return Task.FromResult(StringValue.Create(string.Empty)); - } - - public Task ReadLine(string filePath, decimal lineNumber) - { - this.log.AppendLine($"File.ReadLine(filePath: '{filePath}', lineNumber: '{lineNumber}')"); - return Task.FromResult(StringValue.Create(string.Empty)); - } - - public Task WriteContents(string filePath, string contents) - { - this.log.AppendLine($"File.WriteContents(filePath: '{filePath}', contents: '{contents}')"); - return Task.FromResult(string.Empty); - } - - public Task WriteLine(string filePath, decimal lineNumber, string contents) - { - this.log.AppendLine($"File.WriteLine(filePath: '{filePath}', lineNumber: '{lineNumber}', contents: '{contents}')"); - return Task.FromResult(string.Empty); - } - } - - internal sealed class LoggingFlickrLibrary : IFlickrLibrary - { - private readonly StringBuilder log; - - public LoggingFlickrLibrary(StringBuilder log) - { - this.log = log; - } - } - - internal sealed class LoggingGraphicsWindowLibrary : IGraphicsWindowLibrary - { - private readonly StringBuilder log; - - public LoggingGraphicsWindowLibrary(StringBuilder log) - { - this.log = log; - } - - public event Action KeyDown; - - public event Action KeyUp; - - public event Action MouseDown; - - public event Action MouseMove; - - public event Action MouseUp; - - public event Action TextInput; - - public string Get_BackgroundColor() - { - this.log.AppendLine($"GraphicsWindow.Get_BackgroundColor()"); - return string.Empty; - } - - public void Set_BackgroundColor(string value) - { - this.log.AppendLine($"GraphicsWindow.Set_BackgroundColor('{value}')"); - } - - public string Get_BrushColor() - { - this.log.AppendLine($"GraphicsWindow.Get_BrushColor()"); - return string.Empty; - } - - public void Set_BrushColor(string value) - { - this.log.AppendLine($"GraphicsWindow.Set_BrushColor('{value}')"); - } - - public bool Get_FontBold() - { - this.log.AppendLine($"GraphicsWindow.Get_FontBold()"); - return false; - } - - public void Set_FontBold(bool value) - { - this.log.AppendLine($"GraphicsWindow.Set_FontBold('{value}')"); - } - - public bool Get_FontItalic() - { - this.log.AppendLine($"GraphicsWindow.Get_FontItalic()"); - return false; - } - - public void Set_FontItalic(bool value) - { - this.log.AppendLine($"GraphicsWindow.Set_FontItalic('{value}')"); - } - - public string Get_FontName() - { - this.log.AppendLine($"GraphicsWindow.Get_FontName()"); - return string.Empty; - } - - public void Set_FontName(string value) - { - this.log.AppendLine($"GraphicsWindow.Set_FontName('{value}')"); - } - - public decimal Get_FontSize() - { - this.log.AppendLine($"GraphicsWindow.Get_FontSize()"); - return 0m; - } - - public void Set_FontSize(decimal value) - { - this.log.AppendLine($"GraphicsWindow.Set_FontSize('{value}')"); - } - - public Task Get_Height() - { - this.log.AppendLine($"GraphicsWindow.Get_Height()"); - return Task.FromResult(0m); - } - - public Task Set_Height(decimal value) - { - this.log.AppendLine($"GraphicsWindow.Set_Height('{value}')"); - return Task.CompletedTask; - } - - public string Get_LastKey() - { - this.log.AppendLine($"GraphicsWindow.Get_LastKey()"); - return string.Empty; - } - - public string Get_LastText() - { - this.log.AppendLine($"GraphicsWindow.Get_LastText()"); - return string.Empty; - } - - public decimal Get_MouseX() - { - this.log.AppendLine($"GraphicsWindow.Get_MouseX()"); - return 0m; - } - - public decimal Get_MouseY() - { - this.log.AppendLine($"GraphicsWindow.Get_MouseY()"); - return 0m; - } - - public string Get_PenColor() - { - this.log.AppendLine($"GraphicsWindow.Get_PenColor()"); - return string.Empty; - } - - public void Set_PenColor(string value) - { - this.log.AppendLine($"GraphicsWindow.Set_PenColor('{value}')"); - } - - public decimal Get_PenWidth() - { - this.log.AppendLine($"GraphicsWindow.Get_PenWidth()"); - return 0m; - } - - public void Set_PenWidth(decimal value) - { - this.log.AppendLine($"GraphicsWindow.Set_PenWidth('{value}')"); - } - - public string Get_Title() - { - this.log.AppendLine($"GraphicsWindow.Get_Title()"); - return string.Empty; - } - - public void Set_Title(string value) - { - this.log.AppendLine($"GraphicsWindow.Set_Title('{value}')"); - } - - public Task Get_Width() - { - this.log.AppendLine($"GraphicsWindow.Get_Width()"); - return Task.FromResult(0m); - } - - public Task Set_Width(decimal value) - { - this.log.AppendLine($"GraphicsWindow.Set_Width('{value}')"); - return Task.CompletedTask; - } - - public void Clear() - { - this.log.AppendLine($"GraphicsWindow.Clear()"); - } - - public void DrawBoundText(decimal x, decimal y, decimal width, string text) - { - this.log.AppendLine($"GraphicsWindow.DrawBoundText(x: '{x}', y: '{y}', width: '{width}', text: '{text}')"); - } - - public void DrawEllipse(decimal x, decimal y, decimal width, decimal height) - { - this.log.AppendLine($"GraphicsWindow.DrawEllipse(x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); - } - - public void DrawImage(string imageName, decimal x, decimal y) - { - this.log.AppendLine($"GraphicsWindow.DrawImage(imageName: '{imageName}', x: '{x}', y: '{y}')"); - } - - public void DrawLine(decimal x1, decimal y1, decimal x2, decimal y2) - { - this.log.AppendLine($"GraphicsWindow.DrawLine(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}')"); - } - - public void DrawRectangle(decimal x, decimal y, decimal width, decimal height) - { - this.log.AppendLine($"GraphicsWindow.DrawRectangle(x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); - } - - public void DrawResizedImage(string imageName, decimal x, decimal y, decimal width, decimal height) - { - this.log.AppendLine($"GraphicsWindow.DrawResizedImage(imageName: '{imageName}', x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); - } - - public void DrawText(decimal x, decimal y, string text) - { - this.log.AppendLine($"GraphicsWindow.DrawText(x: '{x}', y: '{y}', text: '{text}')"); - } - - public void DrawTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3) - { - this.log.AppendLine($"GraphicsWindow.DrawTriangle(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}', x3: '{x3}', y3: '{y3}')"); - } - - public void FillEllipse(decimal x, decimal y, decimal width, decimal height) - { - this.log.AppendLine($"GraphicsWindow.FillEllipse(x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); - } - - public void FillRectangle(decimal x, decimal y, decimal width, decimal height) - { - this.log.AppendLine($"GraphicsWindow.FillRectangle(x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); - } - - public void FillTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3) - { - this.log.AppendLine($"GraphicsWindow.FillTriangle(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}', x3: '{x3}', y3: '{y3}')"); - } - - public string GetColorFromRGB(decimal red, decimal green, decimal blue) - { - this.log.AppendLine($"GraphicsWindow.GetColorFromRGB(red: '{red}', green: '{green}', blue: '{blue}')"); - return string.Empty; - } - - public string GetRandomColor() - { - this.log.AppendLine($"GraphicsWindow.GetRandomColor()"); - return string.Empty; - } - - public void Hide() - { - this.log.AppendLine($"GraphicsWindow.Hide()"); - } - - public void SetPixel(decimal x, decimal y, string color) - { - this.log.AppendLine($"GraphicsWindow.SetPixel(x: '{x}', y: '{y}', color: '{color}')"); - } - - public void Show() - { - this.log.AppendLine($"GraphicsWindow.Show()"); - } - - public Task ShowMessage(string text, string title) - { - this.log.AppendLine($"GraphicsWindow.ShowMessage(text: '{text}', title: '{title}')"); - return Task.CompletedTask; - } - } - - internal sealed class LoggingImageListLibrary : IImageListLibrary - { - private readonly StringBuilder log; - - public LoggingImageListLibrary(StringBuilder log) - { - this.log = log; - } - - public decimal GetHeightOfImage(string imageName) - { - this.log.AppendLine($"ImageList.GetHeightOfImage(imageName: '{imageName}')"); - return 0m; - } - - public decimal GetWidthOfImage(string imageName) - { - this.log.AppendLine($"ImageList.GetWidthOfImage(imageName: '{imageName}')"); - return 0m; - } - - public Task LoadImage(string fileNameOrUrl) - { - this.log.AppendLine($"ImageList.LoadImage(fileNameOrUrl: '{fileNameOrUrl}')"); - return Task.FromResult(string.Empty); - } - } - - internal sealed class LoggingMathLibrary : IMathLibrary - { - private readonly StringBuilder log; - - public LoggingMathLibrary(StringBuilder log) - { - this.log = log; - } - - public decimal Get_Pi() - { - this.log.AppendLine($"Math.Get_Pi()"); - return 0m; - } - - public decimal Abs(decimal number) - { - this.log.AppendLine($"Math.Abs(number: '{number}')"); - return 0m; - } - - public decimal ArcCos(decimal cosValue) - { - this.log.AppendLine($"Math.ArcCos(cosValue: '{cosValue}')"); - return 0m; - } - - public decimal ArcSin(decimal sinValue) - { - this.log.AppendLine($"Math.ArcSin(sinValue: '{sinValue}')"); - return 0m; - } - - public decimal ArcTan(decimal tanValue) - { - this.log.AppendLine($"Math.ArcTan(tanValue: '{tanValue}')"); - return 0m; - } - - public decimal Ceiling(decimal number) - { - this.log.AppendLine($"Math.Ceiling(number: '{number}')"); - return 0m; - } - - public decimal Cos(decimal angle) - { - this.log.AppendLine($"Math.Cos(angle: '{angle}')"); - return 0m; - } - - public decimal Floor(decimal number) - { - this.log.AppendLine($"Math.Floor(number: '{number}')"); - return 0m; - } - - public decimal GetDegrees(decimal angle) - { - this.log.AppendLine($"Math.GetDegrees(angle: '{angle}')"); - return 0m; - } - - public decimal GetRadians(decimal angle) - { - this.log.AppendLine($"Math.GetRadians(angle: '{angle}')"); - return 0m; - } - - public decimal GetRandomNumber(decimal maxNumber) - { - this.log.AppendLine($"Math.GetRandomNumber(maxNumber: '{maxNumber}')"); - return 0m; - } - - public decimal Log(decimal number) - { - this.log.AppendLine($"Math.Log(number: '{number}')"); - return 0m; - } - - public decimal Max(decimal number1, decimal number2) - { - this.log.AppendLine($"Math.Max(number1: '{number1}', number2: '{number2}')"); - return 0m; - } - - public decimal Min(decimal number1, decimal number2) - { - this.log.AppendLine($"Math.Min(number1: '{number1}', number2: '{number2}')"); - return 0m; - } - - public decimal NaturalLog(decimal number) - { - this.log.AppendLine($"Math.NaturalLog(number: '{number}')"); - return 0m; - } - - public decimal Power(decimal baseNumber, decimal exponent) - { - this.log.AppendLine($"Math.Power(baseNumber: '{baseNumber}', exponent: '{exponent}')"); - return 0m; - } - - public decimal Remainder(decimal dividend, decimal divisor) - { - this.log.AppendLine($"Math.Remainder(dividend: '{dividend}', divisor: '{divisor}')"); - return 0m; - } - - public decimal Round(decimal number) - { - this.log.AppendLine($"Math.Round(number: '{number}')"); - return 0m; - } - - public decimal Sin(decimal angle) - { - this.log.AppendLine($"Math.Sin(angle: '{angle}')"); - return 0m; - } - - public decimal SquareRoot(decimal number) - { - this.log.AppendLine($"Math.SquareRoot(number: '{number}')"); - return 0m; - } - - public decimal Tan(decimal angle) - { - this.log.AppendLine($"Math.Tan(angle: '{angle}')"); - return 0m; - } - } - - internal sealed class LoggingMouseLibrary : IMouseLibrary - { - private readonly StringBuilder log; - - public LoggingMouseLibrary(StringBuilder log) - { - this.log = log; - } - - public bool Get_IsLeftButtonDown() - { - this.log.AppendLine($"Mouse.Get_IsLeftButtonDown()"); - return false; - } - - public bool Get_IsRightButtonDown() - { - this.log.AppendLine($"Mouse.Get_IsRightButtonDown()"); - return false; - } - - public decimal Get_MouseX() - { - this.log.AppendLine($"Mouse.Get_MouseX()"); - return 0m; - } - - public decimal Get_MouseY() - { - this.log.AppendLine($"Mouse.Get_MouseY()"); - return 0m; - } - - public void HideCursor() - { - this.log.AppendLine($"Mouse.HideCursor()"); - } - - public void ShowCursor() - { - this.log.AppendLine($"Mouse.ShowCursor()"); - } - } - - internal sealed class LoggingNetworkLibrary : INetworkLibrary - { - private readonly StringBuilder log; - - public LoggingNetworkLibrary(StringBuilder log) - { - this.log = log; - } - - public Task DownloadFile(string url) - { - this.log.AppendLine($"Network.DownloadFile(url: '{url}')"); - return Task.FromResult(string.Empty); - } - - public Task GetWebPageContents(string url) - { - this.log.AppendLine($"Network.GetWebPageContents(url: '{url}')"); - return Task.FromResult(string.Empty); - } - } - - internal sealed class LoggingProgramLibrary : IProgramLibrary - { - private readonly StringBuilder log; - - public LoggingProgramLibrary(StringBuilder log) - { - this.log = log; - } - - public Task Delay(decimal milliSeconds) - { - this.log.AppendLine($"Program.Delay(milliSeconds: '{milliSeconds}')"); - return Task.CompletedTask; - } - - public void End() - { - this.log.AppendLine($"Program.End()"); - } - - public void Pause() - { - this.log.AppendLine($"Program.Pause()"); - } - } - - internal sealed class LoggingShapesLibrary : IShapesLibrary - { - private readonly StringBuilder log; - - public LoggingShapesLibrary(StringBuilder log) - { - this.log = log; - } - - public string AddEllipse(decimal width, decimal height) - { - this.log.AppendLine($"Shapes.AddEllipse(width: '{width}', height: '{height}')"); - return string.Empty; - } - - public string AddImage(string imageName) - { - this.log.AppendLine($"Shapes.AddImage(imageName: '{imageName}')"); - return string.Empty; - } - - public string AddLine(decimal x1, decimal y1, decimal x2, decimal y2) - { - this.log.AppendLine($"Shapes.AddLine(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}')"); - return string.Empty; - } - - public string AddRectangle(decimal width, decimal height) - { - this.log.AppendLine($"Shapes.AddRectangle(width: '{width}', height: '{height}')"); - return string.Empty; - } - - public string AddText(string text) - { - this.log.AppendLine($"Shapes.AddText(text: '{text}')"); - return string.Empty; - } - - public string AddTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3) - { - this.log.AppendLine($"Shapes.AddTriangle(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}', x3: '{x3}', y3: '{y3}')"); - return string.Empty; - } - - public Task Animate(string shapeName, decimal x, decimal y, decimal duration) - { - this.log.AppendLine($"Shapes.Animate(shapeName: '{shapeName}', x: '{x}', y: '{y}', duration: '{duration}')"); - return Task.CompletedTask; - } - - public decimal GetLeft(string shapeName) - { - this.log.AppendLine($"Shapes.GetLeft(shapeName: '{shapeName}')"); - return 0m; - } - - public decimal GetOpacity(string shapeName) - { - this.log.AppendLine($"Shapes.GetOpacity(shapeName: '{shapeName}')"); - return 0m; - } - - public decimal GetTop(string shapeName) - { - this.log.AppendLine($"Shapes.GetTop(shapeName: '{shapeName}')"); - return 0m; - } - - public void HideShape(string shapeName) - { - this.log.AppendLine($"Shapes.HideShape(shapeName: '{shapeName}')"); - } - - public void Move(string shapeName, decimal x, decimal y) - { - this.log.AppendLine($"Shapes.Move(shapeName: '{shapeName}', x: '{x}', y: '{y}')"); - } - - public void Remove(string shapeName) - { - this.log.AppendLine($"Shapes.Remove(shapeName: '{shapeName}')"); - } - - public void Rotate(string shapeName, decimal angle) - { - this.log.AppendLine($"Shapes.Rotate(shapeName: '{shapeName}', angle: '{angle}')"); - } - - public void SetOpacity(string shapeName, decimal level) - { - this.log.AppendLine($"Shapes.SetOpacity(shapeName: '{shapeName}', level: '{level}')"); - } - - public void SetText(string shapeName, string text) - { - this.log.AppendLine($"Shapes.SetText(shapeName: '{shapeName}', text: '{text}')"); - } - - public void ShowShape(string shapeName) - { - this.log.AppendLine($"Shapes.ShowShape(shapeName: '{shapeName}')"); - } - - public void Zoom(string shapeName, decimal scaleX, decimal scaleY) - { - this.log.AppendLine($"Shapes.Zoom(shapeName: '{shapeName}', scaleX: '{scaleX}', scaleY: '{scaleY}')"); - } - } - - internal sealed class LoggingSoundLibrary : ISoundLibrary - { - private readonly StringBuilder log; - - public LoggingSoundLibrary(StringBuilder log) - { - this.log = log; - } - } - - internal sealed class LoggingStackLibrary : IStackLibrary - { - private readonly StringBuilder log; - - public LoggingStackLibrary(StringBuilder log) - { - this.log = log; - } - - public decimal GetCount(string stackName) - { - this.log.AppendLine($"Stack.GetCount(stackName: '{stackName}')"); - return 0m; - } - - public string PopValue(string stackName) - { - this.log.AppendLine($"Stack.PopValue(stackName: '{stackName}')"); - return string.Empty; - } - - public void PushValue(string stackName, string value) - { - this.log.AppendLine($"Stack.PushValue(stackName: '{stackName}', value: '{value}')"); - } - } - - internal sealed class LoggingTextLibrary : ITextLibrary - { - private readonly StringBuilder log; - - public LoggingTextLibrary(StringBuilder log) - { - this.log = log; - } - - public string Append(string text1, string text2) - { - this.log.AppendLine($"Text.Append(text1: '{text1}', text2: '{text2}')"); - return string.Empty; - } - - public string ConvertToLowerCase(string text) - { - this.log.AppendLine($"Text.ConvertToLowerCase(text: '{text}')"); - return string.Empty; - } - - public string ConvertToUpperCase(string text) - { - this.log.AppendLine($"Text.ConvertToUpperCase(text: '{text}')"); - return string.Empty; - } - - public bool EndsWith(string text, string subText) - { - this.log.AppendLine($"Text.EndsWith(text: '{text}', subText: '{subText}')"); - return false; - } - - public string GetCharacter(decimal characterCode) - { - this.log.AppendLine($"Text.GetCharacter(characterCode: '{characterCode}')"); - return string.Empty; - } - - public decimal GetCharacterCode(string character) - { - this.log.AppendLine($"Text.GetCharacterCode(character: '{character}')"); - return 0m; - } - - public decimal GetIndexOf(string text, string subText) - { - this.log.AppendLine($"Text.GetIndexOf(text: '{text}', subText: '{subText}')"); - return 0m; - } - - public decimal GetLength(string text) - { - this.log.AppendLine($"Text.GetLength(text: '{text}')"); - return 0m; - } - - public string GetSubText(string text, decimal start, decimal length) - { - this.log.AppendLine($"Text.GetSubText(text: '{text}', start: '{start}', length: '{length}')"); - return string.Empty; - } - - public string GetSubTextToEnd(string text, decimal start) - { - this.log.AppendLine($"Text.GetSubTextToEnd(text: '{text}', start: '{start}')"); - return string.Empty; - } - - public bool IsSubText(string text, string subText) - { - this.log.AppendLine($"Text.IsSubText(text: '{text}', subText: '{subText}')"); - return false; - } - - public bool StartsWith(string text, string subText) - { - this.log.AppendLine($"Text.StartsWith(text: '{text}', subText: '{subText}')"); - return false; - } - } - - internal sealed class LoggingTextWindowLibrary : ITextWindowLibrary - { - private readonly StringBuilder log; - - public LoggingTextWindowLibrary(StringBuilder log) - { - this.log = log; - } - - public string Get_BackgroundColor() - { - this.log.AppendLine($"TextWindow.Get_BackgroundColor()"); - return string.Empty; - } - - public void Set_BackgroundColor(string value) - { - this.log.AppendLine($"TextWindow.Set_BackgroundColor('{value}')"); - } - - public string Get_ForegroundColor() - { - this.log.AppendLine($"TextWindow.Get_ForegroundColor()"); - return string.Empty; - } - - public void Set_ForegroundColor(string value) - { - this.log.AppendLine($"TextWindow.Set_ForegroundColor('{value}')"); - } - - public string Get_Title() - { - this.log.AppendLine($"TextWindow.Get_Title()"); - return string.Empty; - } - - public void Set_Title(string value) - { - this.log.AppendLine($"TextWindow.Set_Title('{value}')"); - } - - public void Clear() - { - this.log.AppendLine($"TextWindow.Clear()"); - } - - public string Read() - { - this.log.AppendLine($"TextWindow.Read()"); - return string.Empty; - } - - public decimal ReadNumber() - { - this.log.AppendLine($"TextWindow.ReadNumber()"); - return 0m; - } - - public Task Write(string data) - { - this.log.AppendLine($"TextWindow.Write(data: '{data}')"); - return Task.CompletedTask; - } - - public Task WriteLine(string data) - { - this.log.AppendLine($"TextWindow.WriteLine(data: '{data}')"); - return Task.CompletedTask; - } - } - - internal sealed class LoggingTimerLibrary : ITimerLibrary - { - private readonly StringBuilder log; - - public LoggingTimerLibrary(StringBuilder log) - { - this.log = log; - } - - public event Action Tick; - - public decimal Get_Interval() - { - this.log.AppendLine($"Timer.Get_Interval()"); - return 0m; - } - - public void Set_Interval(decimal value) - { - this.log.AppendLine($"Timer.Set_Interval('{value}')"); - } - - public void Pause() - { - this.log.AppendLine($"Timer.Pause()"); - } - - public void Resume() - { - this.log.AppendLine($"Timer.Resume()"); - } - } - - internal sealed class LoggingTurtleLibrary : ITurtleLibrary - { - private readonly StringBuilder log; - - public LoggingTurtleLibrary(StringBuilder log) - { - this.log = log; - } - - public decimal Get_Angle() - { - this.log.AppendLine($"Turtle.Get_Angle()"); - return 0m; - } - - public void Set_Angle(decimal value) - { - this.log.AppendLine($"Turtle.Set_Angle('{value}')"); - } - - public decimal Get_Speed() - { - this.log.AppendLine($"Turtle.Get_Speed()"); - return 0m; - } - - public void Set_Speed(decimal value) - { - this.log.AppendLine($"Turtle.Set_Speed('{value}')"); - } - - public decimal Get_X() - { - this.log.AppendLine($"Turtle.Get_X()"); - return 0m; - } - - public void Set_X(decimal value) - { - this.log.AppendLine($"Turtle.Set_X('{value}')"); - } - - public decimal Get_Y() - { - this.log.AppendLine($"Turtle.Get_Y()"); - return 0m; - } - - public void Set_Y(decimal value) - { - this.log.AppendLine($"Turtle.Set_Y('{value}')"); - } - - public void Hide() - { - this.log.AppendLine($"Turtle.Hide()"); - } - - public Task Move(decimal distance) - { - this.log.AppendLine($"Turtle.Move(distance: '{distance}')"); - return Task.CompletedTask; - } - - public Task MoveTo(decimal x, decimal y) - { - this.log.AppendLine($"Turtle.MoveTo(x: '{x}', y: '{y}')"); - return Task.CompletedTask; - } - - public void PenDown() - { - this.log.AppendLine($"Turtle.PenDown()"); - } - - public void PenUp() - { - this.log.AppendLine($"Turtle.PenUp()"); - } - - public void Show() - { - this.log.AppendLine($"Turtle.Show()"); - } - - public Task Turn(decimal angle) - { - this.log.AppendLine($"Turtle.Turn(angle: '{angle}')"); - return Task.CompletedTask; - } - - public Task TurnLeft() - { - this.log.AppendLine($"Turtle.TurnLeft()"); - return Task.CompletedTask; - } - - public Task TurnRight() - { - this.log.AppendLine($"Turtle.TurnRight()"); - return Task.CompletedTask; - } - } - - internal sealed class LoggingEngineLibraries : IEngineLibraries - { - public LoggingEngineLibraries(StringBuilder log) - { - this.Array = new LoggingArrayLibrary(log); - this.Clock = new LoggingClockLibrary(log); - this.Controls = new LoggingControlsLibrary(log); - this.Desktop = new LoggingDesktopLibrary(log); - this.Dictionary = new LoggingDictionaryLibrary(log); - this.File = new LoggingFileLibrary(log); - this.Flickr = new LoggingFlickrLibrary(log); - this.GraphicsWindow = new LoggingGraphicsWindowLibrary(log); - this.ImageList = new LoggingImageListLibrary(log); - this.Math = new LoggingMathLibrary(log); - this.Mouse = new LoggingMouseLibrary(log); - this.Network = new LoggingNetworkLibrary(log); - this.Program = new LoggingProgramLibrary(log); - this.Shapes = new LoggingShapesLibrary(log); - this.Sound = new LoggingSoundLibrary(log); - this.Stack = new LoggingStackLibrary(log); - this.Text = new LoggingTextLibrary(log); - this.TextWindow = new LoggingTextWindowLibrary(log); - this.Timer = new LoggingTimerLibrary(log); - this.Turtle = new LoggingTurtleLibrary(log); - } - - public IArrayLibrary Array { get; private set; } - - public IClockLibrary Clock { get; private set; } - - public IControlsLibrary Controls { get; private set; } - - public IDesktopLibrary Desktop { get; private set; } - - public IDictionaryLibrary Dictionary { get; private set; } - - public IFileLibrary File { get; private set; } - - public IFlickrLibrary Flickr { get; private set; } - - public IGraphicsWindowLibrary GraphicsWindow { get; private set; } - - public IImageListLibrary ImageList { get; private set; } - - public IMathLibrary Math { get; private set; } - - public IMouseLibrary Mouse { get; private set; } - - public INetworkLibrary Network { get; private set; } - - public IProgramLibrary Program { get; private set; } - - public IShapesLibrary Shapes { get; private set; } - - public ISoundLibrary Sound { get; private set; } - - public IStackLibrary Stack { get; private set; } - - public ITextLibrary Text { get; private set; } - - public ITextWindowLibrary TextWindow { get; private set; } - - public ITimerLibrary Timer { get; private set; } - - public ITurtleLibrary Turtle { get; private set; } - } - - #pragma warning restore CS0067 // The event '{0}' is never used -} +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +/// +/// This file is auto-generated by a build task. It shouldn't be edited by hand. +/// +namespace SmallBasic.Tests +{ + #pragma warning disable CS0067 // The event '{0}' is never used + using System; + using System.Text; + using System.Threading.Tasks; + using SmallBasic.Compiler.Runtime; + + internal sealed class LoggingArrayLibrary : IArrayLibrary + { + private readonly StringBuilder log; + + public LoggingArrayLibrary(StringBuilder log) + { + this.log = log; + } + + public bool ContainsIndex(ArrayValue array, string index) + { + this.log.AppendLine($"Array.ContainsIndex(array: '{array.ToDisplayString()}', index: '{index}')"); + return false; + } + + public bool ContainsValue(ArrayValue array, string value) + { + this.log.AppendLine($"Array.ContainsValue(array: '{array.ToDisplayString()}', value: '{value}')"); + return false; + } + + public ArrayValue GetAllIndices(ArrayValue array) + { + this.log.AppendLine($"Array.GetAllIndices(array: '{array.ToDisplayString()}')"); + return new ArrayValue(); + } + + public decimal GetItemCount(ArrayValue array) + { + this.log.AppendLine($"Array.GetItemCount(array: '{array.ToDisplayString()}')"); + return 0m; + } + + public BaseValue GetValue(string arrayName, string index) + { + this.log.AppendLine($"Array.GetValue(arrayName: '{arrayName}', index: '{index}')"); + return StringValue.Create(string.Empty); + } + + public bool IsArray(BaseValue array) + { + this.log.AppendLine($"Array.IsArray(array: '{array.ToDisplayString()}')"); + return false; + } + + public void RemoveValue(string arrayName, string index) + { + this.log.AppendLine($"Array.RemoveValue(arrayName: '{arrayName}', index: '{index}')"); + } + + public void SetValue(string arrayName, string index, BaseValue value) + { + this.log.AppendLine($"Array.SetValue(arrayName: '{arrayName}', index: '{index}', value: '{value.ToDisplayString()}')"); + } + } + + internal sealed class LoggingClockLibrary : IClockLibrary + { + private readonly StringBuilder log; + + public LoggingClockLibrary(StringBuilder log) + { + this.log = log; + } + + public string Get_Date() + { + this.log.AppendLine($"Clock.Get_Date()"); + return string.Empty; + } + + public decimal Get_Day() + { + this.log.AppendLine($"Clock.Get_Day()"); + return 0m; + } + + public decimal Get_ElapsedMilliseconds() + { + this.log.AppendLine($"Clock.Get_ElapsedMilliseconds()"); + return 0m; + } + + public decimal Get_Hour() + { + this.log.AppendLine($"Clock.Get_Hour()"); + return 0m; + } + + public decimal Get_Millisecond() + { + this.log.AppendLine($"Clock.Get_Millisecond()"); + return 0m; + } + + public decimal Get_Minute() + { + this.log.AppendLine($"Clock.Get_Minute()"); + return 0m; + } + + public decimal Get_Month() + { + this.log.AppendLine($"Clock.Get_Month()"); + return 0m; + } + + public decimal Get_Second() + { + this.log.AppendLine($"Clock.Get_Second()"); + return 0m; + } + + public string Get_Time() + { + this.log.AppendLine($"Clock.Get_Time()"); + return string.Empty; + } + + public string Get_WeekDay() + { + this.log.AppendLine($"Clock.Get_WeekDay()"); + return string.Empty; + } + + public decimal Get_Year() + { + this.log.AppendLine($"Clock.Get_Year()"); + return 0m; + } + } + + internal sealed class LoggingControlsLibrary : IControlsLibrary + { + private readonly StringBuilder log; + + public LoggingControlsLibrary(StringBuilder log) + { + this.log = log; + } + + public event Action ButtonClicked; + + public event Action TextTyped; + + public string Get_LastClickedButton() + { + this.log.AppendLine($"Controls.Get_LastClickedButton()"); + return string.Empty; + } + + public string Get_LastTypedTextBox() + { + this.log.AppendLine($"Controls.Get_LastTypedTextBox()"); + return string.Empty; + } + + public string AddButton(string caption, decimal left, decimal top) + { + this.log.AppendLine($"Controls.AddButton(caption: '{caption}', left: '{left}', top: '{top}')"); + return string.Empty; + } + + public string AddMultiLineTextBox(decimal left, decimal top) + { + this.log.AppendLine($"Controls.AddMultiLineTextBox(left: '{left}', top: '{top}')"); + return string.Empty; + } + + public string AddTextBox(decimal left, decimal top) + { + this.log.AppendLine($"Controls.AddTextBox(left: '{left}', top: '{top}')"); + return string.Empty; + } + + public string GetButtonCaption(string buttonName) + { + this.log.AppendLine($"Controls.GetButtonCaption(buttonName: '{buttonName}')"); + return string.Empty; + } + + public string GetTextBoxText(string textBoxName) + { + this.log.AppendLine($"Controls.GetTextBoxText(textBoxName: '{textBoxName}')"); + return string.Empty; + } + + public void HideControl(string controlName) + { + this.log.AppendLine($"Controls.HideControl(controlName: '{controlName}')"); + } + + public void Move(string control, decimal x, decimal y) + { + this.log.AppendLine($"Controls.Move(control: '{control}', x: '{x}', y: '{y}')"); + } + + public void Remove(string controlName) + { + this.log.AppendLine($"Controls.Remove(controlName: '{controlName}')"); + } + + public void SetButtonCaption(string buttonName, string caption) + { + this.log.AppendLine($"Controls.SetButtonCaption(buttonName: '{buttonName}', caption: '{caption}')"); + } + + public void SetSize(string control, decimal width, decimal height) + { + this.log.AppendLine($"Controls.SetSize(control: '{control}', width: '{width}', height: '{height}')"); + } + + public void SetTextBoxText(string textBoxName, string text) + { + this.log.AppendLine($"Controls.SetTextBoxText(textBoxName: '{textBoxName}', text: '{text}')"); + } + + public void ShowControl(string controlName) + { + this.log.AppendLine($"Controls.ShowControl(controlName: '{controlName}')"); + } + } + + internal sealed class LoggingDesktopLibrary : IDesktopLibrary + { + private readonly StringBuilder log; + + public LoggingDesktopLibrary(StringBuilder log) + { + this.log = log; + } + } + + internal sealed class LoggingDictionaryLibrary : IDictionaryLibrary + { + private readonly StringBuilder log; + + public LoggingDictionaryLibrary(StringBuilder log) + { + this.log = log; + } + } + + internal sealed class LoggingFileLibrary : IFileLibrary + { + private readonly StringBuilder log; + + public LoggingFileLibrary(StringBuilder log) + { + this.log = log; + } + + public string Get_LastError() + { + this.log.AppendLine($"File.Get_LastError()"); + return string.Empty; + } + + public void Set_LastError(string value) + { + this.log.AppendLine($"File.Set_LastError('{value}')"); + } + + public Task AppendContents(string filePath, string contents) + { + this.log.AppendLine($"File.AppendContents(filePath: '{filePath}', contents: '{contents}')"); + return Task.FromResult(string.Empty); + } + + public Task CopyFile(string sourceFilePath, string destinationFilePath) + { + this.log.AppendLine($"File.CopyFile(sourceFilePath: '{sourceFilePath}', destinationFilePath: '{destinationFilePath}')"); + return Task.FromResult(string.Empty); + } + + public Task CreateDirectory(string directoryPath) + { + this.log.AppendLine($"File.CreateDirectory(directoryPath: '{directoryPath}')"); + return Task.FromResult(string.Empty); + } + + public Task DeleteDirectory(string directoryPath) + { + this.log.AppendLine($"File.DeleteDirectory(directoryPath: '{directoryPath}')"); + return Task.FromResult(string.Empty); + } + + public Task DeleteFile(string filePath) + { + this.log.AppendLine($"File.DeleteFile(filePath: '{filePath}')"); + return Task.FromResult(string.Empty); + } + + public Task GetDirectories(string directoryPath) + { + this.log.AppendLine($"File.GetDirectories(directoryPath: '{directoryPath}')"); + return Task.FromResult(StringValue.Create(string.Empty)); + } + + public Task GetFiles(string directoryPath) + { + this.log.AppendLine($"File.GetFiles(directoryPath: '{directoryPath}')"); + return Task.FromResult(StringValue.Create(string.Empty)); + } + + public Task GetTemporaryFilePath() + { + this.log.AppendLine($"File.GetTemporaryFilePath()"); + return Task.FromResult(StringValue.Create(string.Empty)); + } + + public Task InsertLine(string filePath, decimal lineNumber, string contents) + { + this.log.AppendLine($"File.InsertLine(filePath: '{filePath}', lineNumber: '{lineNumber}', contents: '{contents}')"); + return Task.FromResult(string.Empty); + } + + public Task ReadContents(string filePath) + { + this.log.AppendLine($"File.ReadContents(filePath: '{filePath}')"); + return Task.FromResult(StringValue.Create(string.Empty)); + } + + public Task ReadLine(string filePath, decimal lineNumber) + { + this.log.AppendLine($"File.ReadLine(filePath: '{filePath}', lineNumber: '{lineNumber}')"); + return Task.FromResult(StringValue.Create(string.Empty)); + } + + public Task WriteContents(string filePath, string contents) + { + this.log.AppendLine($"File.WriteContents(filePath: '{filePath}', contents: '{contents}')"); + return Task.FromResult(string.Empty); + } + + public Task WriteLine(string filePath, decimal lineNumber, string contents) + { + this.log.AppendLine($"File.WriteLine(filePath: '{filePath}', lineNumber: '{lineNumber}', contents: '{contents}')"); + return Task.FromResult(string.Empty); + } + } + + internal sealed class LoggingFlickrLibrary : IFlickrLibrary + { + private readonly StringBuilder log; + + public LoggingFlickrLibrary(StringBuilder log) + { + this.log = log; + } + } + + internal sealed class LoggingGraphicsWindowLibrary : IGraphicsWindowLibrary + { + private readonly StringBuilder log; + + public LoggingGraphicsWindowLibrary(StringBuilder log) + { + this.log = log; + } + + public event Action KeyDown; + + public event Action KeyUp; + + public event Action MouseDown; + + public event Action MouseMove; + + public event Action MouseUp; + + public event Action TextInput; + + public string Get_BackgroundColor() + { + this.log.AppendLine($"GraphicsWindow.Get_BackgroundColor()"); + return string.Empty; + } + + public void Set_BackgroundColor(string value) + { + this.log.AppendLine($"GraphicsWindow.Set_BackgroundColor('{value}')"); + } + + public string Get_BrushColor() + { + this.log.AppendLine($"GraphicsWindow.Get_BrushColor()"); + return string.Empty; + } + + public void Set_BrushColor(string value) + { + this.log.AppendLine($"GraphicsWindow.Set_BrushColor('{value}')"); + } + + public bool Get_FontBold() + { + this.log.AppendLine($"GraphicsWindow.Get_FontBold()"); + return false; + } + + public void Set_FontBold(bool value) + { + this.log.AppendLine($"GraphicsWindow.Set_FontBold('{value}')"); + } + + public bool Get_FontItalic() + { + this.log.AppendLine($"GraphicsWindow.Get_FontItalic()"); + return false; + } + + public void Set_FontItalic(bool value) + { + this.log.AppendLine($"GraphicsWindow.Set_FontItalic('{value}')"); + } + + public string Get_FontName() + { + this.log.AppendLine($"GraphicsWindow.Get_FontName()"); + return string.Empty; + } + + public void Set_FontName(string value) + { + this.log.AppendLine($"GraphicsWindow.Set_FontName('{value}')"); + } + + public decimal Get_FontSize() + { + this.log.AppendLine($"GraphicsWindow.Get_FontSize()"); + return 0m; + } + + public void Set_FontSize(decimal value) + { + this.log.AppendLine($"GraphicsWindow.Set_FontSize('{value}')"); + } + + public Task Get_Height() + { + this.log.AppendLine($"GraphicsWindow.Get_Height()"); + return Task.FromResult(0m); + } + + public Task Set_Height(decimal value) + { + this.log.AppendLine($"GraphicsWindow.Set_Height('{value}')"); + return Task.CompletedTask; + } + + public string Get_LastKey() + { + this.log.AppendLine($"GraphicsWindow.Get_LastKey()"); + return string.Empty; + } + + public string Get_LastText() + { + this.log.AppendLine($"GraphicsWindow.Get_LastText()"); + return string.Empty; + } + + public decimal Get_MouseX() + { + this.log.AppendLine($"GraphicsWindow.Get_MouseX()"); + return 0m; + } + + public decimal Get_MouseY() + { + this.log.AppendLine($"GraphicsWindow.Get_MouseY()"); + return 0m; + } + + public string Get_PenColor() + { + this.log.AppendLine($"GraphicsWindow.Get_PenColor()"); + return string.Empty; + } + + public void Set_PenColor(string value) + { + this.log.AppendLine($"GraphicsWindow.Set_PenColor('{value}')"); + } + + public decimal Get_PenWidth() + { + this.log.AppendLine($"GraphicsWindow.Get_PenWidth()"); + return 0m; + } + + public void Set_PenWidth(decimal value) + { + this.log.AppendLine($"GraphicsWindow.Set_PenWidth('{value}')"); + } + + public string Get_Title() + { + this.log.AppendLine($"GraphicsWindow.Get_Title()"); + return string.Empty; + } + + public void Set_Title(string value) + { + this.log.AppendLine($"GraphicsWindow.Set_Title('{value}')"); + } + + public Task Get_Width() + { + this.log.AppendLine($"GraphicsWindow.Get_Width()"); + return Task.FromResult(0m); + } + + public Task Set_Width(decimal value) + { + this.log.AppendLine($"GraphicsWindow.Set_Width('{value}')"); + return Task.CompletedTask; + } + + public void Clear() + { + this.log.AppendLine($"GraphicsWindow.Clear()"); + } + + public void DrawBoundText(decimal x, decimal y, decimal width, string text) + { + this.log.AppendLine($"GraphicsWindow.DrawBoundText(x: '{x}', y: '{y}', width: '{width}', text: '{text}')"); + } + + public void DrawEllipse(decimal x, decimal y, decimal width, decimal height) + { + this.log.AppendLine($"GraphicsWindow.DrawEllipse(x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); + } + + public void DrawImage(string imageName, decimal x, decimal y) + { + this.log.AppendLine($"GraphicsWindow.DrawImage(imageName: '{imageName}', x: '{x}', y: '{y}')"); + } + + public void DrawLine(decimal x1, decimal y1, decimal x2, decimal y2) + { + this.log.AppendLine($"GraphicsWindow.DrawLine(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}')"); + } + + public void DrawRectangle(decimal x, decimal y, decimal width, decimal height) + { + this.log.AppendLine($"GraphicsWindow.DrawRectangle(x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); + } + + public void DrawResizedImage(string imageName, decimal x, decimal y, decimal width, decimal height) + { + this.log.AppendLine($"GraphicsWindow.DrawResizedImage(imageName: '{imageName}', x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); + } + + public void DrawText(decimal x, decimal y, string text) + { + this.log.AppendLine($"GraphicsWindow.DrawText(x: '{x}', y: '{y}', text: '{text}')"); + } + + public void DrawTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3) + { + this.log.AppendLine($"GraphicsWindow.DrawTriangle(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}', x3: '{x3}', y3: '{y3}')"); + } + + public void FillEllipse(decimal x, decimal y, decimal width, decimal height) + { + this.log.AppendLine($"GraphicsWindow.FillEllipse(x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); + } + + public void FillRectangle(decimal x, decimal y, decimal width, decimal height) + { + this.log.AppendLine($"GraphicsWindow.FillRectangle(x: '{x}', y: '{y}', width: '{width}', height: '{height}')"); + } + + public void FillTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3) + { + this.log.AppendLine($"GraphicsWindow.FillTriangle(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}', x3: '{x3}', y3: '{y3}')"); + } + + public string GetColorFromRGB(decimal red, decimal green, decimal blue) + { + this.log.AppendLine($"GraphicsWindow.GetColorFromRGB(red: '{red}', green: '{green}', blue: '{blue}')"); + return string.Empty; + } + + public string GetRandomColor() + { + this.log.AppendLine($"GraphicsWindow.GetRandomColor()"); + return string.Empty; + } + + public void Hide() + { + this.log.AppendLine($"GraphicsWindow.Hide()"); + } + + public void SetPixel(decimal x, decimal y, string color) + { + this.log.AppendLine($"GraphicsWindow.SetPixel(x: '{x}', y: '{y}', color: '{color}')"); + } + + public void Show() + { + this.log.AppendLine($"GraphicsWindow.Show()"); + } + + public Task ShowMessage(string text, string title) + { + this.log.AppendLine($"GraphicsWindow.ShowMessage(text: '{text}', title: '{title}')"); + return Task.CompletedTask; + } + } + + internal sealed class LoggingImageListLibrary : IImageListLibrary + { + private readonly StringBuilder log; + + public LoggingImageListLibrary(StringBuilder log) + { + this.log = log; + } + + public decimal GetHeightOfImage(string imageName) + { + this.log.AppendLine($"ImageList.GetHeightOfImage(imageName: '{imageName}')"); + return 0m; + } + + public decimal GetWidthOfImage(string imageName) + { + this.log.AppendLine($"ImageList.GetWidthOfImage(imageName: '{imageName}')"); + return 0m; + } + + public Task LoadImage(string fileNameOrUrl) + { + this.log.AppendLine($"ImageList.LoadImage(fileNameOrUrl: '{fileNameOrUrl}')"); + return Task.FromResult(string.Empty); + } + } + + internal sealed class LoggingMathLibrary : IMathLibrary + { + private readonly StringBuilder log; + + public LoggingMathLibrary(StringBuilder log) + { + this.log = log; + } + + public decimal Get_Pi() + { + this.log.AppendLine($"Math.Get_Pi()"); + return 0m; + } + + public decimal Abs(decimal number) + { + this.log.AppendLine($"Math.Abs(number: '{number}')"); + return 0m; + } + + public decimal ArcCos(decimal cosValue) + { + this.log.AppendLine($"Math.ArcCos(cosValue: '{cosValue}')"); + return 0m; + } + + public decimal ArcSin(decimal sinValue) + { + this.log.AppendLine($"Math.ArcSin(sinValue: '{sinValue}')"); + return 0m; + } + + public decimal ArcTan(decimal tanValue) + { + this.log.AppendLine($"Math.ArcTan(tanValue: '{tanValue}')"); + return 0m; + } + + public decimal Ceiling(decimal number) + { + this.log.AppendLine($"Math.Ceiling(number: '{number}')"); + return 0m; + } + + public decimal Cos(decimal angle) + { + this.log.AppendLine($"Math.Cos(angle: '{angle}')"); + return 0m; + } + + public decimal Floor(decimal number) + { + this.log.AppendLine($"Math.Floor(number: '{number}')"); + return 0m; + } + + public decimal GetDegrees(decimal angle) + { + this.log.AppendLine($"Math.GetDegrees(angle: '{angle}')"); + return 0m; + } + + public decimal GetRadians(decimal angle) + { + this.log.AppendLine($"Math.GetRadians(angle: '{angle}')"); + return 0m; + } + + public decimal GetRandomNumber(decimal maxNumber) + { + this.log.AppendLine($"Math.GetRandomNumber(maxNumber: '{maxNumber}')"); + return 0m; + } + + public decimal Log(decimal number) + { + this.log.AppendLine($"Math.Log(number: '{number}')"); + return 0m; + } + + public decimal Max(decimal number1, decimal number2) + { + this.log.AppendLine($"Math.Max(number1: '{number1}', number2: '{number2}')"); + return 0m; + } + + public decimal Min(decimal number1, decimal number2) + { + this.log.AppendLine($"Math.Min(number1: '{number1}', number2: '{number2}')"); + return 0m; + } + + public decimal NaturalLog(decimal number) + { + this.log.AppendLine($"Math.NaturalLog(number: '{number}')"); + return 0m; + } + + public decimal Power(decimal baseNumber, decimal exponent) + { + this.log.AppendLine($"Math.Power(baseNumber: '{baseNumber}', exponent: '{exponent}')"); + return 0m; + } + + public decimal Remainder(decimal dividend, decimal divisor) + { + this.log.AppendLine($"Math.Remainder(dividend: '{dividend}', divisor: '{divisor}')"); + return 0m; + } + + public decimal Round(decimal number) + { + this.log.AppendLine($"Math.Round(number: '{number}')"); + return 0m; + } + + public decimal Sin(decimal angle) + { + this.log.AppendLine($"Math.Sin(angle: '{angle}')"); + return 0m; + } + + public decimal SquareRoot(decimal number) + { + this.log.AppendLine($"Math.SquareRoot(number: '{number}')"); + return 0m; + } + + public decimal Tan(decimal angle) + { + this.log.AppendLine($"Math.Tan(angle: '{angle}')"); + return 0m; + } + } + + internal sealed class LoggingMouseLibrary : IMouseLibrary + { + private readonly StringBuilder log; + + public LoggingMouseLibrary(StringBuilder log) + { + this.log = log; + } + + public bool Get_IsLeftButtonDown() + { + this.log.AppendLine($"Mouse.Get_IsLeftButtonDown()"); + return false; + } + + public bool Get_IsRightButtonDown() + { + this.log.AppendLine($"Mouse.Get_IsRightButtonDown()"); + return false; + } + + public decimal Get_MouseX() + { + this.log.AppendLine($"Mouse.Get_MouseX()"); + return 0m; + } + + public decimal Get_MouseY() + { + this.log.AppendLine($"Mouse.Get_MouseY()"); + return 0m; + } + + public void HideCursor() + { + this.log.AppendLine($"Mouse.HideCursor()"); + } + + public void ShowCursor() + { + this.log.AppendLine($"Mouse.ShowCursor()"); + } + } + + internal sealed class LoggingNetworkLibrary : INetworkLibrary + { + private readonly StringBuilder log; + + public LoggingNetworkLibrary(StringBuilder log) + { + this.log = log; + } + + public Task DownloadFile(string url) + { + this.log.AppendLine($"Network.DownloadFile(url: '{url}')"); + return Task.FromResult(string.Empty); + } + + public Task GetWebPageContents(string url) + { + this.log.AppendLine($"Network.GetWebPageContents(url: '{url}')"); + return Task.FromResult(string.Empty); + } + } + + internal sealed class LoggingProgramLibrary : IProgramLibrary + { + private readonly StringBuilder log; + + public LoggingProgramLibrary(StringBuilder log) + { + this.log = log; + } + + public Task Delay(decimal milliSeconds) + { + this.log.AppendLine($"Program.Delay(milliSeconds: '{milliSeconds}')"); + return Task.CompletedTask; + } + + public void End() + { + this.log.AppendLine($"Program.End()"); + } + + public void Pause() + { + this.log.AppendLine($"Program.Pause()"); + } + } + + internal sealed class LoggingShapesLibrary : IShapesLibrary + { + private readonly StringBuilder log; + + public LoggingShapesLibrary(StringBuilder log) + { + this.log = log; + } + + public string AddEllipse(decimal width, decimal height) + { + this.log.AppendLine($"Shapes.AddEllipse(width: '{width}', height: '{height}')"); + return string.Empty; + } + + public string AddImage(string imageName) + { + this.log.AppendLine($"Shapes.AddImage(imageName: '{imageName}')"); + return string.Empty; + } + + public string AddLine(decimal x1, decimal y1, decimal x2, decimal y2) + { + this.log.AppendLine($"Shapes.AddLine(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}')"); + return string.Empty; + } + + public string AddRectangle(decimal width, decimal height) + { + this.log.AppendLine($"Shapes.AddRectangle(width: '{width}', height: '{height}')"); + return string.Empty; + } + + public string AddText(string text) + { + this.log.AppendLine($"Shapes.AddText(text: '{text}')"); + return string.Empty; + } + + public string AddTriangle(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3) + { + this.log.AppendLine($"Shapes.AddTriangle(x1: '{x1}', y1: '{y1}', x2: '{x2}', y2: '{y2}', x3: '{x3}', y3: '{y3}')"); + return string.Empty; + } + + public Task Animate(string shapeName, decimal x, decimal y, decimal duration) + { + this.log.AppendLine($"Shapes.Animate(shapeName: '{shapeName}', x: '{x}', y: '{y}', duration: '{duration}')"); + return Task.CompletedTask; + } + + public decimal GetLeft(string shapeName) + { + this.log.AppendLine($"Shapes.GetLeft(shapeName: '{shapeName}')"); + return 0m; + } + + public decimal GetOpacity(string shapeName) + { + this.log.AppendLine($"Shapes.GetOpacity(shapeName: '{shapeName}')"); + return 0m; + } + + public decimal GetTop(string shapeName) + { + this.log.AppendLine($"Shapes.GetTop(shapeName: '{shapeName}')"); + return 0m; + } + + public void HideShape(string shapeName) + { + this.log.AppendLine($"Shapes.HideShape(shapeName: '{shapeName}')"); + } + + public void Move(string shapeName, decimal x, decimal y) + { + this.log.AppendLine($"Shapes.Move(shapeName: '{shapeName}', x: '{x}', y: '{y}')"); + } + + public void Remove(string shapeName) + { + this.log.AppendLine($"Shapes.Remove(shapeName: '{shapeName}')"); + } + + public void Rotate(string shapeName, decimal angle) + { + this.log.AppendLine($"Shapes.Rotate(shapeName: '{shapeName}', angle: '{angle}')"); + } + + public void SetOpacity(string shapeName, decimal level) + { + this.log.AppendLine($"Shapes.SetOpacity(shapeName: '{shapeName}', level: '{level}')"); + } + + public void SetText(string shapeName, string text) + { + this.log.AppendLine($"Shapes.SetText(shapeName: '{shapeName}', text: '{text}')"); + } + + public void ShowShape(string shapeName) + { + this.log.AppendLine($"Shapes.ShowShape(shapeName: '{shapeName}')"); + } + + public void Zoom(string shapeName, decimal scaleX, decimal scaleY) + { + this.log.AppendLine($"Shapes.Zoom(shapeName: '{shapeName}', scaleX: '{scaleX}', scaleY: '{scaleY}')"); + } + } + + internal sealed class LoggingSoundLibrary : ISoundLibrary + { + private readonly StringBuilder log; + + public LoggingSoundLibrary(StringBuilder log) + { + this.log = log; + } + } + + internal sealed class LoggingStackLibrary : IStackLibrary + { + private readonly StringBuilder log; + + public LoggingStackLibrary(StringBuilder log) + { + this.log = log; + } + + public decimal GetCount(string stackName) + { + this.log.AppendLine($"Stack.GetCount(stackName: '{stackName}')"); + return 0m; + } + + public string PopValue(string stackName) + { + this.log.AppendLine($"Stack.PopValue(stackName: '{stackName}')"); + return string.Empty; + } + + public void PushValue(string stackName, string value) + { + this.log.AppendLine($"Stack.PushValue(stackName: '{stackName}', value: '{value}')"); + } + } + + internal sealed class LoggingTextLibrary : ITextLibrary + { + private readonly StringBuilder log; + + public LoggingTextLibrary(StringBuilder log) + { + this.log = log; + } + + public string Append(string text1, string text2) + { + this.log.AppendLine($"Text.Append(text1: '{text1}', text2: '{text2}')"); + return string.Empty; + } + + public string ConvertToLowerCase(string text) + { + this.log.AppendLine($"Text.ConvertToLowerCase(text: '{text}')"); + return string.Empty; + } + + public string ConvertToUpperCase(string text) + { + this.log.AppendLine($"Text.ConvertToUpperCase(text: '{text}')"); + return string.Empty; + } + + public bool EndsWith(string text, string subText) + { + this.log.AppendLine($"Text.EndsWith(text: '{text}', subText: '{subText}')"); + return false; + } + + public string GetCharacter(decimal characterCode) + { + this.log.AppendLine($"Text.GetCharacter(characterCode: '{characterCode}')"); + return string.Empty; + } + + public decimal GetCharacterCode(string character) + { + this.log.AppendLine($"Text.GetCharacterCode(character: '{character}')"); + return 0m; + } + + public decimal GetIndexOf(string text, string subText) + { + this.log.AppendLine($"Text.GetIndexOf(text: '{text}', subText: '{subText}')"); + return 0m; + } + + public decimal GetLength(string text) + { + this.log.AppendLine($"Text.GetLength(text: '{text}')"); + return 0m; + } + + public string GetSubText(string text, decimal start, decimal length) + { + this.log.AppendLine($"Text.GetSubText(text: '{text}', start: '{start}', length: '{length}')"); + return string.Empty; + } + + public string GetSubTextToEnd(string text, decimal start) + { + this.log.AppendLine($"Text.GetSubTextToEnd(text: '{text}', start: '{start}')"); + return string.Empty; + } + + public bool IsSubText(string text, string subText) + { + this.log.AppendLine($"Text.IsSubText(text: '{text}', subText: '{subText}')"); + return false; + } + + public bool StartsWith(string text, string subText) + { + this.log.AppendLine($"Text.StartsWith(text: '{text}', subText: '{subText}')"); + return false; + } + } + + internal sealed class LoggingTextWindowLibrary : ITextWindowLibrary + { + private readonly StringBuilder log; + + public LoggingTextWindowLibrary(StringBuilder log) + { + this.log = log; + } + + public string Get_BackgroundColor() + { + this.log.AppendLine($"TextWindow.Get_BackgroundColor()"); + return string.Empty; + } + + public void Set_BackgroundColor(string value) + { + this.log.AppendLine($"TextWindow.Set_BackgroundColor('{value}')"); + } + + public string Get_ForegroundColor() + { + this.log.AppendLine($"TextWindow.Get_ForegroundColor()"); + return string.Empty; + } + + public void Set_ForegroundColor(string value) + { + this.log.AppendLine($"TextWindow.Set_ForegroundColor('{value}')"); + } + + public string Get_Title() + { + this.log.AppendLine($"TextWindow.Get_Title()"); + return string.Empty; + } + + public void Set_Title(string value) + { + this.log.AppendLine($"TextWindow.Set_Title('{value}')"); + } + + public void Clear() + { + this.log.AppendLine($"TextWindow.Clear()"); + } + + public string Read() + { + this.log.AppendLine($"TextWindow.Read()"); + return string.Empty; + } + + public decimal ReadNumber() + { + this.log.AppendLine($"TextWindow.ReadNumber()"); + return 0m; + } + + public Task Write(string data) + { + this.log.AppendLine($"TextWindow.Write(data: '{data}')"); + return Task.CompletedTask; + } + + public Task WriteLine(string data) + { + this.log.AppendLine($"TextWindow.WriteLine(data: '{data}')"); + return Task.CompletedTask; + } + } + + internal sealed class LoggingTimerLibrary : ITimerLibrary + { + private readonly StringBuilder log; + + public LoggingTimerLibrary(StringBuilder log) + { + this.log = log; + } + + public event Action Tick; + + public decimal Get_Interval() + { + this.log.AppendLine($"Timer.Get_Interval()"); + return 0m; + } + + public void Set_Interval(decimal value) + { + this.log.AppendLine($"Timer.Set_Interval('{value}')"); + } + + public void Pause() + { + this.log.AppendLine($"Timer.Pause()"); + } + + public void Resume() + { + this.log.AppendLine($"Timer.Resume()"); + } + } + + internal sealed class LoggingTurtleLibrary : ITurtleLibrary + { + private readonly StringBuilder log; + + public LoggingTurtleLibrary(StringBuilder log) + { + this.log = log; + } + + public decimal Get_Angle() + { + this.log.AppendLine($"Turtle.Get_Angle()"); + return 0m; + } + + public void Set_Angle(decimal value) + { + this.log.AppendLine($"Turtle.Set_Angle('{value}')"); + } + + public decimal Get_Speed() + { + this.log.AppendLine($"Turtle.Get_Speed()"); + return 0m; + } + + public void Set_Speed(decimal value) + { + this.log.AppendLine($"Turtle.Set_Speed('{value}')"); + } + + public decimal Get_X() + { + this.log.AppendLine($"Turtle.Get_X()"); + return 0m; + } + + public void Set_X(decimal value) + { + this.log.AppendLine($"Turtle.Set_X('{value}')"); + } + + public decimal Get_Y() + { + this.log.AppendLine($"Turtle.Get_Y()"); + return 0m; + } + + public void Set_Y(decimal value) + { + this.log.AppendLine($"Turtle.Set_Y('{value}')"); + } + + public void Hide() + { + this.log.AppendLine($"Turtle.Hide()"); + } + + public Task Move(decimal distance) + { + this.log.AppendLine($"Turtle.Move(distance: '{distance}')"); + return Task.CompletedTask; + } + + public Task MoveTo(decimal x, decimal y) + { + this.log.AppendLine($"Turtle.MoveTo(x: '{x}', y: '{y}')"); + return Task.CompletedTask; + } + + public void PenDown() + { + this.log.AppendLine($"Turtle.PenDown()"); + } + + public void PenUp() + { + this.log.AppendLine($"Turtle.PenUp()"); + } + + public void Show() + { + this.log.AppendLine($"Turtle.Show()"); + } + + public Task Turn(decimal angle) + { + this.log.AppendLine($"Turtle.Turn(angle: '{angle}')"); + return Task.CompletedTask; + } + + public Task TurnLeft() + { + this.log.AppendLine($"Turtle.TurnLeft()"); + return Task.CompletedTask; + } + + public Task TurnRight() + { + this.log.AppendLine($"Turtle.TurnRight()"); + return Task.CompletedTask; + } + } + + internal sealed class LoggingEngineLibraries : IEngineLibraries + { + public LoggingEngineLibraries(StringBuilder log) + { + this.Array = new LoggingArrayLibrary(log); + this.Clock = new LoggingClockLibrary(log); + this.Controls = new LoggingControlsLibrary(log); + this.Desktop = new LoggingDesktopLibrary(log); + this.Dictionary = new LoggingDictionaryLibrary(log); + this.File = new LoggingFileLibrary(log); + this.Flickr = new LoggingFlickrLibrary(log); + this.GraphicsWindow = new LoggingGraphicsWindowLibrary(log); + this.ImageList = new LoggingImageListLibrary(log); + this.Math = new LoggingMathLibrary(log); + this.Mouse = new LoggingMouseLibrary(log); + this.Network = new LoggingNetworkLibrary(log); + this.Program = new LoggingProgramLibrary(log); + this.Shapes = new LoggingShapesLibrary(log); + this.Sound = new LoggingSoundLibrary(log); + this.Stack = new LoggingStackLibrary(log); + this.Text = new LoggingTextLibrary(log); + this.TextWindow = new LoggingTextWindowLibrary(log); + this.Timer = new LoggingTimerLibrary(log); + this.Turtle = new LoggingTurtleLibrary(log); + } + + public IArrayLibrary Array { get; private set; } + + public IClockLibrary Clock { get; private set; } + + public IControlsLibrary Controls { get; private set; } + + public IDesktopLibrary Desktop { get; private set; } + + public IDictionaryLibrary Dictionary { get; private set; } + + public IFileLibrary File { get; private set; } + + public IFlickrLibrary Flickr { get; private set; } + + public IGraphicsWindowLibrary GraphicsWindow { get; private set; } + + public IImageListLibrary ImageList { get; private set; } + + public IMathLibrary Math { get; private set; } + + public IMouseLibrary Mouse { get; private set; } + + public INetworkLibrary Network { get; private set; } + + public IProgramLibrary Program { get; private set; } + + public IShapesLibrary Shapes { get; private set; } + + public ISoundLibrary Sound { get; private set; } + + public IStackLibrary Stack { get; private set; } + + public ITextLibrary Text { get; private set; } + + public ITextWindowLibrary TextWindow { get; private set; } + + public ITimerLibrary Timer { get; private set; } + + public ITurtleLibrary Turtle { get; private set; } + } + + #pragma warning restore CS0067 // The event '{0}' is never used +} diff --git a/Source/SmallBasic.Tests/Runtime/NewFeaturesTests.cs b/Source/SmallBasic.Tests/Runtime/NewFeaturesTests.cs new file mode 100644 index 00000000..a50f93c1 --- /dev/null +++ b/Source/SmallBasic.Tests/Runtime/NewFeaturesTests.cs @@ -0,0 +1,118 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for license information. +// + +namespace SmallBasic.Tests.Runtime +{ + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using SmallBasic.Compiler; + using SmallBasic.Compiler.Scanning; + using SmallBasic.Utilities; + using Xunit; + + public sealed class NewFeaturesTests : IClassFixture + { + [Fact] + public Task ItEvaluatesFunctionWithParametersAndReturn() + { + return new SmallBasicCompilation(@" +Function Add(a, b) + Return a + b +EndFunction + +x = Add(10, 20) +").VerifyRealRuntime(@" +a = 10 +b = 20 +x = 30"); + } + + [Fact] + public Task ItEvaluatesSubroutine() + { + return new SmallBasicCompilation(@" +Sub Multiply + res = a * b +EndSub + +a = 5 +b = 24 +Multiply() +").VerifyRealRuntime(@" +a = 5 +b = 24 +res = 120"); + } + + [Fact] + public Task ItEvaluatesImportWithFileResolver() + { + var files = new Dictionary + { + { + "math_helper.sb", @" +Function Square(x) + Return x * x +EndFunction +" + } + }; + + var compilation = new SmallBasicCompilation(@" +Import ""math_helper.sb"" +ans = Square(6) +", fileResolver: path => files.ContainsKey(path) ? files[path] : null); + + return compilation.VerifyRealRuntime(@" +x = 6 +ans = 36"); + } + + [Fact] + public Task ItEvaluatesSelectCaseStatement() + { + return new SmallBasicCompilation(@" +val = 2 +res = """" +Select Case val + Case 1 + res = ""one"" + Case 2 + res = ""two"" + Else + res = ""other"" +EndSelect +").VerifyRealRuntime(@" +val = 2 +res = two"); + } + + [Fact] + public Task ItEvaluatesTryCatchStatement() + { + return new SmallBasicCompilation(@" +a = 10 +b = 20 +Try + c = a + b +Catch ex + c = 0 +EndTry +").VerifyRealRuntime(@" +a = 10 +b = 20 +c = 30"); + } + + [Fact] + public void ItProvidesCompletionsForNewKeywords() + { + var compilation = new SmallBasicCompilation(@"F"); + var items = compilation.ProvideCompletionItems((0, 1)); + FluentAssertions.AssertionExtensions.Should(items.Any(item => item.label == "Function")).BeTrue(); + FluentAssertions.AssertionExtensions.Should(items.Any(item => item.label == "Fn")).BeTrue(); + } + } +} diff --git a/Source/SmallBasic.Tests/SmallBasic.Tests.csproj b/Source/SmallBasic.Tests/SmallBasic.Tests.csproj index 25f75fd6..fde28e17 100644 --- a/Source/SmallBasic.Tests/SmallBasic.Tests.csproj +++ b/Source/SmallBasic.Tests/SmallBasic.Tests.csproj @@ -1,12 +1,11 @@  - netcoreapp2.0 + net8.0 - diff --git a/Source/SmallBasic.Tests/TestExtensions.cs b/Source/SmallBasic.Tests/TestExtensions.cs index 427de616..494fe60f 100644 --- a/Source/SmallBasic.Tests/TestExtensions.cs +++ b/Source/SmallBasic.Tests/TestExtensions.cs @@ -15,7 +15,6 @@ namespace SmallBasic.Tests using SmallBasic.Compiler.Binding; using SmallBasic.Compiler.Diagnostics; using SmallBasic.Compiler.Runtime; - using SmallBasic.Editor.Libraries; using SmallBasic.Utilities; internal static class TestExtensions @@ -34,7 +33,7 @@ public static async Task VerifyExecutionState(this SmallBasicC { compilation.VerifyDiagnostics(); - SmallBasicEngine engine = new SmallBasicEngine(compilation, new LibrariesCollection()); + SmallBasicEngine engine = new SmallBasicEngine(compilation, new BuiltInLibraries()); engine.Mode = mode; await engine.Execute().ConfigureAwait(false); engine.State.Should().Be(executionState); @@ -44,7 +43,7 @@ public static async Task VerifyExecutionState(this SmallBasicC public static Task VerifyRealRuntime(this SmallBasicCompilation compilation, string memoryContents = default) { - return VerifyRuntimeAux(compilation, new LibrariesCollection(), memoryContents); + return VerifyRuntimeAux(compilation, new BuiltInLibraries(), memoryContents); } public static async Task VerifyLoggingRuntime(this SmallBasicCompilation compilation, string expectedLog = default, string memoryContents = default) diff --git a/global.json b/global.json index 8696cb39..68b0305d 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,6 @@ { "sdk": { - "version": "2.1.816" + "version": "8.0.124", + "rollForward": "latestMinor" } }