diff --git a/.circleci.meta b/.circleci.meta new file mode 100644 index 0000000..e5fa4ad --- /dev/null +++ b/.circleci.meta @@ -0,0 +1,10 @@ + +fileFormatVersion: 2 +guid: 05068f18ac4e4268a880020669e33a09 + +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..2b601f7 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,12 @@ +version: 2.1 + +orbs: + hello: circleci/hello-build@0.0.7 # uses the circleci/buildpack-deps Docker image + +workflows: + "Hello Workflow": + jobs: + - hello/hello-build: + filters: + branches: + ignore: /.*/ \ No newline at end of file diff --git a/.circleci/config.yml.meta b/.circleci/config.yml.meta new file mode 100644 index 0000000..1d0d0c3 --- /dev/null +++ b/.circleci/config.yml.meta @@ -0,0 +1,10 @@ + +fileFormatVersion: 2 +guid: 12bb7667390448aeb17b6d00879ca027 + +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: + diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 3c4efe2..0000000 --- a/.gitignore +++ /dev/null @@ -1,261 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# DNX -project.lock.json -project.fragment.lock.json -artifacts/ - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -#*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignoreable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc \ No newline at end of file diff --git a/NOTICE.md.meta b/NOTICE.md.meta new file mode 100644 index 0000000..77186ed --- /dev/null +++ b/NOTICE.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4cdb69be0d721a64da347d87bf2b5a05 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins.meta b/Plugins.meta new file mode 100644 index 0000000..ee5dfc4 --- /dev/null +++ b/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ab0fc7d222839524babba13431fe598b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis.meta b/Plugins/se.zifro.mellis.meta new file mode 100644 index 0000000..ac8f3c3 --- /dev/null +++ b/Plugins/se.zifro.mellis.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: afb201621e434b046bc351a640aeebf5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis.python3.meta b/Plugins/se.zifro.mellis.python3.meta new file mode 100644 index 0000000..8f3f074 --- /dev/null +++ b/Plugins/se.zifro.mellis.python3.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a637eece6de327c4dbbd6304c11fa837 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis.python3/Antlr4.Runtime.Standard.dll b/Plugins/se.zifro.mellis.python3/Antlr4.Runtime.Standard.dll new file mode 100755 index 0000000..f98e781 Binary files /dev/null and b/Plugins/se.zifro.mellis.python3/Antlr4.Runtime.Standard.dll differ diff --git a/Plugins/se.zifro.mellis.python3/Antlr4.Runtime.Standard.dll.meta b/Plugins/se.zifro.mellis.python3/Antlr4.Runtime.Standard.dll.meta new file mode 100644 index 0000000..91a08ba --- /dev/null +++ b/Plugins/se.zifro.mellis.python3/Antlr4.Runtime.Standard.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 34f4e5e0343f482fb52cd8e495b19037 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.deps.json b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.deps.json new file mode 100644 index 0000000..ce0ca52 --- /dev/null +++ b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.deps.json @@ -0,0 +1,105 @@ +{ + "runtimeTarget": { + "name": ".NETStandard,Version=v2.0/", + "signature": "dfc1788138745de46283ec7160394ce1bfddf3e4" + }, + "compilationOptions": {}, + "targets": { + ".NETStandard,Version=v2.0": {}, + ".NETStandard,Version=v2.0/": { + "Mellis.Lang.Python3/0.8.8.0": { + "dependencies": { + "Antlr4.Runtime.Standard": "4.7.2", + "Mellis": "0.4.4", + "Mellis.Core": "0.4.4", + "Mellis.Tools": "0.4.4", + "NETStandard.Library": "2.0.3" + }, + "runtime": { + "Mellis.Lang.Python3.dll": {} + } + }, + "Antlr4.Runtime.Standard/4.7.2": { + "dependencies": { + "NETStandard.Library": "2.0.3" + }, + "runtime": { + "lib/netstandard1.3/Antlr4.Runtime.Standard.dll": { + "assemblyVersion": "4.7.2.0", + "fileVersion": "4.7.2.0" + } + } + }, + "Microsoft.NETCore.Platforms/1.1.0": {}, + "NETStandard.Library/2.0.3": { + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "Mellis/0.4.4": { + "dependencies": { + "Mellis.Core": "0.4.4" + }, + "runtime": { + "Mellis.dll": {} + } + }, + "Mellis.Core/0.4.4": { + "runtime": { + "Mellis.Core.dll": {} + } + }, + "Mellis.Tools/0.4.4": { + "dependencies": { + "Mellis.Core": "0.4.4" + }, + "runtime": { + "Mellis.Tools.dll": {} + } + } + } + }, + "libraries": { + "Mellis.Lang.Python3/0.8.8.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Antlr4.Runtime.Standard/4.7.2": { + "type": "package", + "serviceable": true, + "sha512": "sha512-vT7inRjayVvSQ+tvm9h9Ovygz5Nh9DgvTkt5w6G6M8Wpsqz6rQpou/pLsShwrrZTOjHgCiizbWjO3G/NzMihyw==", + "path": "antlr4.runtime.standard/4.7.2", + "hashPath": "antlr4.runtime.standard.4.7.2.nupkg.sha512" + }, + "Microsoft.NETCore.Platforms/1.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==", + "path": "microsoft.netcore.platforms/1.1.0", + "hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512" + }, + "NETStandard.Library/2.0.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "path": "netstandard.library/2.0.3", + "hashPath": "netstandard.library.2.0.3.nupkg.sha512" + }, + "Mellis/0.4.4": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Mellis.Core/0.4.4": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Mellis.Tools/0.4.4": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.deps.json.meta b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.deps.json.meta new file mode 100644 index 0000000..9ace161 --- /dev/null +++ b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.deps.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 31a2e562562b0c747bfa71946095807b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.dll b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.dll new file mode 100644 index 0000000..12b498d Binary files /dev/null and b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.dll differ diff --git a/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.dll.meta b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.dll.meta new file mode 100644 index 0000000..27c98f6 --- /dev/null +++ b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 17b5a1a17355b5e42a5fc1b0a6573be5 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.pdb b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.pdb new file mode 100644 index 0000000..8862671 Binary files /dev/null and b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.pdb differ diff --git a/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.pdb.meta b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.pdb.meta new file mode 100644 index 0000000..35009dc --- /dev/null +++ b/Plugins/se.zifro.mellis.python3/Mellis.Lang.Python3.pdb.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9757171fd4f907143b8b413e51763203 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis/Mellis.Core.deps.json b/Plugins/se.zifro.mellis/Mellis.Core.deps.json new file mode 100644 index 0000000..0f105f4 --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.Core.deps.json @@ -0,0 +1,47 @@ +{ + "runtimeTarget": { + "name": ".NETStandard,Version=v2.0/", + "signature": "cfe1dc2a80602aef150a12815387068463a61a0d" + }, + "compilationOptions": {}, + "targets": { + ".NETStandard,Version=v2.0": {}, + ".NETStandard,Version=v2.0/": { + "Mellis.Core/0.4.4.0": { + "dependencies": { + "NETStandard.Library": "2.0.3" + }, + "runtime": { + "Mellis.Core.dll": {} + } + }, + "Microsoft.NETCore.Platforms/1.1.0": {}, + "NETStandard.Library/2.0.3": { + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + } + } + }, + "libraries": { + "Mellis.Core/0.4.4.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Microsoft.NETCore.Platforms/1.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==", + "path": "microsoft.netcore.platforms/1.1.0", + "hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512" + }, + "NETStandard.Library/2.0.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "path": "netstandard.library/2.0.3", + "hashPath": "netstandard.library.2.0.3.nupkg.sha512" + } + } +} \ No newline at end of file diff --git a/Plugins/se.zifro.mellis/Mellis.Core.deps.json.meta b/Plugins/se.zifro.mellis/Mellis.Core.deps.json.meta new file mode 100644 index 0000000..4d3a951 --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.Core.deps.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9e32c94626f643c2a14b347d174a1673 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis/Mellis.Core.dll b/Plugins/se.zifro.mellis/Mellis.Core.dll new file mode 100644 index 0000000..85d6657 Binary files /dev/null and b/Plugins/se.zifro.mellis/Mellis.Core.dll differ diff --git a/Plugins/se.zifro.mellis/Mellis.Core.dll.meta b/Plugins/se.zifro.mellis/Mellis.Core.dll.meta new file mode 100644 index 0000000..012e170 --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.Core.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 17ad5fd03c099e140838b1870de6d1d6 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis/Mellis.Core.pdb b/Plugins/se.zifro.mellis/Mellis.Core.pdb new file mode 100644 index 0000000..3a53679 Binary files /dev/null and b/Plugins/se.zifro.mellis/Mellis.Core.pdb differ diff --git a/Plugins/se.zifro.mellis/Mellis.Core.pdb.meta b/Plugins/se.zifro.mellis/Mellis.Core.pdb.meta new file mode 100644 index 0000000..710db2d --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.Core.pdb.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 846ec5b151d1fb543bde1974d64621c0 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis/Mellis.Tools.deps.json b/Plugins/se.zifro.mellis/Mellis.Tools.deps.json new file mode 100644 index 0000000..34f0327 --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.Tools.deps.json @@ -0,0 +1,58 @@ +{ + "runtimeTarget": { + "name": ".NETStandard,Version=v2.0/", + "signature": "cfe1dc2a80602aef150a12815387068463a61a0d" + }, + "compilationOptions": {}, + "targets": { + ".NETStandard,Version=v2.0": {}, + ".NETStandard,Version=v2.0/": { + "Mellis.Tools/0.4.4.0": { + "dependencies": { + "Mellis.Core": "0.4.4", + "NETStandard.Library": "2.0.3" + }, + "runtime": { + "Mellis.Tools.dll": {} + } + }, + "Microsoft.NETCore.Platforms/1.1.0": {}, + "NETStandard.Library/2.0.3": { + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "Mellis.Core/0.4.4": { + "runtime": { + "Mellis.Core.dll": {} + } + } + } + }, + "libraries": { + "Mellis.Tools/0.4.4.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Microsoft.NETCore.Platforms/1.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==", + "path": "microsoft.netcore.platforms/1.1.0", + "hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512" + }, + "NETStandard.Library/2.0.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "path": "netstandard.library/2.0.3", + "hashPath": "netstandard.library.2.0.3.nupkg.sha512" + }, + "Mellis.Core/0.4.4": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/Plugins/se.zifro.mellis/Mellis.Tools.deps.json.meta b/Plugins/se.zifro.mellis/Mellis.Tools.deps.json.meta new file mode 100644 index 0000000..2a7758d --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.Tools.deps.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2d13d081f48a41488c790078d18d7541 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis/Mellis.Tools.dll b/Plugins/se.zifro.mellis/Mellis.Tools.dll new file mode 100644 index 0000000..fe417e7 Binary files /dev/null and b/Plugins/se.zifro.mellis/Mellis.Tools.dll differ diff --git a/Plugins/se.zifro.mellis/Mellis.Tools.dll.meta b/Plugins/se.zifro.mellis/Mellis.Tools.dll.meta new file mode 100644 index 0000000..6a9b46b --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.Tools.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: 04bd8be9d3897684ab9d7636c77d0874 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis/Mellis.Tools.pdb b/Plugins/se.zifro.mellis/Mellis.Tools.pdb new file mode 100644 index 0000000..72a9bb9 Binary files /dev/null and b/Plugins/se.zifro.mellis/Mellis.Tools.pdb differ diff --git a/Plugins/se.zifro.mellis/Mellis.Tools.pdb.meta b/Plugins/se.zifro.mellis/Mellis.Tools.pdb.meta new file mode 100644 index 0000000..187010c --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.Tools.pdb.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0a81447f83be10843b136375cf9d6af8 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis/Mellis.deps.json b/Plugins/se.zifro.mellis/Mellis.deps.json new file mode 100644 index 0000000..3cb23d6 --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.deps.json @@ -0,0 +1,58 @@ +{ + "runtimeTarget": { + "name": ".NETStandard,Version=v2.0/", + "signature": "cfe1dc2a80602aef150a12815387068463a61a0d" + }, + "compilationOptions": {}, + "targets": { + ".NETStandard,Version=v2.0": {}, + ".NETStandard,Version=v2.0/": { + "Mellis/0.4.4.0": { + "dependencies": { + "Mellis.Core": "0.4.4", + "NETStandard.Library": "2.0.3" + }, + "runtime": { + "Mellis.dll": {} + } + }, + "Microsoft.NETCore.Platforms/1.1.0": {}, + "NETStandard.Library/2.0.3": { + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "Mellis.Core/0.4.4": { + "runtime": { + "Mellis.Core.dll": {} + } + } + } + }, + "libraries": { + "Mellis/0.4.4.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Microsoft.NETCore.Platforms/1.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==", + "path": "microsoft.netcore.platforms/1.1.0", + "hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512" + }, + "NETStandard.Library/2.0.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "path": "netstandard.library/2.0.3", + "hashPath": "netstandard.library.2.0.3.nupkg.sha512" + }, + "Mellis.Core/0.4.4": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/Plugins/se.zifro.mellis/Mellis.deps.json.meta b/Plugins/se.zifro.mellis/Mellis.deps.json.meta new file mode 100644 index 0000000..67093a3 --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.deps.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1e7b129e3a4947908fe650f495da9879 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis/Mellis.dll b/Plugins/se.zifro.mellis/Mellis.dll new file mode 100644 index 0000000..2650a5b Binary files /dev/null and b/Plugins/se.zifro.mellis/Mellis.dll differ diff --git a/Plugins/se.zifro.mellis/Mellis.dll.meta b/Plugins/se.zifro.mellis/Mellis.dll.meta new file mode 100644 index 0000000..8265439 --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.dll.meta @@ -0,0 +1,32 @@ +fileFormatVersion: 2 +guid: ff87c554b0f5443781921f3c5a106846 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/se.zifro.mellis/Mellis.pdb b/Plugins/se.zifro.mellis/Mellis.pdb new file mode 100644 index 0000000..a7bd948 Binary files /dev/null and b/Plugins/se.zifro.mellis/Mellis.pdb differ diff --git a/Plugins/se.zifro.mellis/Mellis.pdb.meta b/Plugins/se.zifro.mellis/Mellis.pdb.meta new file mode 100644 index 0000000..73b03b7 --- /dev/null +++ b/Plugins/se.zifro.mellis/Mellis.pdb.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 036f6dd11a0c43c38519850d6318ea50 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/README.md b/README.md index 11eafed..3ffac84 100644 --- a/README.md +++ b/README.md @@ -1 +1,129 @@ -# TestCompiler \ No newline at end of file +# Zifro Mellis compiler + +## For _Unity Package Manager_ + +This is a release meant for be used via UPM (Unity Package Manager). + +## Installation + +Minimal Unity version: `2018.3.10f1` or `2019.1.0b9` + +### 1. Add package + +Add the following inside the `dependencies` object in your `/Packages/manifest.json`: + +If unsure of which variant to use, go for the HTTPS variant. + +#### 1.1 HTTPS variant + +```diff +@@ Packages/manifest.json @@ +{ + "dependencies": { ++ "se.zifro.mellis": "https://github.com/zardan/compiler.git#upm", + "com.unity.analytics": "3.2.2", + "com.unity.collab-proxy": "1.2.16", + "com.unity.package-manager-ui": "2.0.7", + "com.unity.modules.ai": "1.0.0", + + /* ... rest of Unity packages ... */ + } +} +``` + +#### 1.2 SSH variant + +```diff +@@ Packages/manifest.json @@ +{ + "dependencies": { ++ "se.zifro.mellis": "ssh://git@github.com/zardan/compiler.git#upm", + "com.unity.analytics": "3.2.2", + "com.unity.collab-proxy": "1.2.16", + "com.unity.package-manager-ui": "2.0.7", + "com.unity.modules.ai": "1.0.0", + + /* ... rest of Unity packages ... */ + } +} +``` + +> **Note**: The Mellis repository is (at time or writing) private, therefore you must be logged in to `git` on your local machine when UPM updates. +> +> UPM does not ask for credentials so they must be cached or have a SSH key on your computer. If you're not logged in it will fail on downloading the package. + +### 2. Enable embedded resource (if targetting WebGL) + +Zifro Mellis compiler relies heavily on embedded resources when it comes to localized exceptions. +In Unity, embedded resources are disabled by default in WebGL builds. + +#### 2.1 Enable via script + +[Josh Peterson recommends](https://forum.unity.com/threads/enabling-embedded-resources-with-webgl.326069/) enabling the settings via an editor script. +To do so, create the following script in an editor folder (ex: `/Assets/Editor/WebGLEditorScript.cs`): + +```cs +using UnityEditor; +public class WebGLEditorScript +{ + [MenuItem("WebGL/Enable Embedded Resources")] + public static void EnableErrorMessageTesting() + { + PlayerSettings.SetPropertyBool("useEmbeddedResources", true, BuildTargetGroup.WebGL); + } +} +``` + +Then from the menu bar follow "WebGL > Enable Embedded Resources". Clicked once, and the setting should be active. + +#### 2.2 Enable manually in file + +> This operation can only be achived if your project settings are serialized in text mode. + +Change the `webGLUseEmbeddedResources` setting to `1` inside your `/ProjectSettings/ProjectSettings.asset` + +```diff +@@ ProjectSettings/ProjectSettings.asset @@ PlayerSettings: + webGLModulesDirectory: + webGLTemplate: APPLICATION:Default + webGLAnalyzeBuildSize: 0 +- webGLUseEmbeddedResources: 0 ++ webGLUseEmbeddedResources: 1 + webGLCompressionFormat: 1 + webGLLinkerTarget: 1 + webGLThreadsSupport: 0 +``` + +## Updating + +There's at time of writing no way to update via the Package Manager UI. + +To do it manually, remove the lock of `se.zifro.mellis` in your `/Packages/manifest.json` + +```diff +@@ Packages/manifest.json @@ +{ + "dependencies": { + "se.zifro.mellis": "ssh://git@github.com/zardan/compiler.git#upm", + "com.unity.analytics": "3.2.2", + "com.unity.collab-proxy": "1.2.16", + "com.unity.package-manager-ui": "2.0.7", + "com.unity.modules.ai": "1.0.0", + + /* ... rest of Unity packages ... */ + }, + "lock": { +- "se.zifro.mellis": { +- "hash": "8a61a6b637735194520a896ed3bafc322f7710ce", +- "revision": "upm" +- } + } +} +``` + +Then jump back into Unity and watch it gather the latest release. + +--- + +Zifro Mellis compiler is developed, maintained, and owned by © Zifro AB ([zifro.se](https://zifro.se/)) + diff --git a/README.md.meta b/README.md.meta new file mode 100644 index 0000000..81ce384 --- /dev/null +++ b/README.md.meta @@ -0,0 +1,10 @@ + +fileFormatVersion: 2 +guid: 4d96da99b62046f092b7a6e117847d41 + +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: + diff --git a/package.json b/package.json new file mode 100644 index 0000000..1bb0d6f --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "se.zifro.mellis", + "displayName": "Zifro Mellis Compiler", + "description": "A compiler for code walking and looking at variables.\n\nCurrently supports:\n- Python3", + "version": "0.1.0", + "unity": "2018.3", + "license": "", + "repository": { + "type": "git", + "url": "git+https://github.com/zardan/compiler.git" + }, + "author": "Zifro AB", + "dependencies": { + } +} diff --git a/package.json.meta b/package.json.meta new file mode 100644 index 0000000..485cd1a --- /dev/null +++ b/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 459c9e0ce27dfbd428456bc989a11ee2 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MSTestSettings.runsettings b/src/MSTestSettings.runsettings deleted file mode 100644 index 2a07cda..0000000 --- a/src/MSTestSettings.runsettings +++ /dev/null @@ -1,9 +0,0 @@ - - - - - 0 - MethodLevel - - - diff --git a/src/Mellis.Core.Tests/Mellis.Core.Tests.csproj b/src/Mellis.Core.Tests/Mellis.Core.Tests.csproj deleted file mode 100644 index 169335c..0000000 --- a/src/Mellis.Core.Tests/Mellis.Core.Tests.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - netcoreapp2.1 - - false - - 7.2 - - - - - - - - - - - - - diff --git a/src/Mellis.Core.Tests/SourceReferenceTests.cs b/src/Mellis.Core.Tests/SourceReferenceTests.cs deleted file mode 100644 index e75b8cb..0000000 --- a/src/Mellis.Core.Tests/SourceReferenceTests.cs +++ /dev/null @@ -1,242 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Mellis.Core.Entities; - -namespace Mellis.Core.Tests -{ - [TestClass] - public class SourceReferenceTests - { - public static void AssertExactCompare(SourceReference expected, SourceReference actual) - { - Assert.AreEqual(expected.IsFromClr, actual.IsFromClr, "CLR flag does not match."); - Assert.AreEqual(expected.FromRow, actual.FromRow, "From row does not match."); - Assert.AreEqual(expected.FromColumn, actual.FromColumn, "From column does not match."); - Assert.AreEqual(expected.ToRow, actual.ToRow, "To row does not match."); - Assert.AreEqual(expected.ToColumn, actual.ToColumn, "To column does not match."); - } - - public static void AssertEquals(SourceReference expected, SourceReference actual) - { - Assert.IsTrue(expected.Equals(actual), $"expected({expected}).Equals(actual({actual})) is not true"); - Assert.IsTrue(actual.Equals(expected), $"actual({actual}).Equals(expected({expected})) is not true"); - Assert.IsTrue(expected == actual, $"expected({expected}) == actual({actual}) is not true"); - Assert.IsTrue(actual == expected, $"actual({actual}) == expected({expected}) is not true"); - Assert.IsFalse(expected != actual, $"expected({expected}) != actual({actual}) is not false"); - Assert.IsFalse(actual != expected, $"actual({actual}) != expected({expected}) is not false"); - } - - public static void AssertNotEquals(SourceReference expected, SourceReference actual) - { - Assert.IsFalse(expected.Equals(actual), $"expected({expected}).Equals(actual({actual})) is not false"); - Assert.IsFalse(actual.Equals(expected), $"actual({actual}).Equals(expected({expected})) is not false"); - Assert.IsFalse(expected == actual, $"expected({expected}) == actual({actual}) is not false"); - Assert.IsFalse(actual == expected, $"actual({actual}) == expected({expected}) is not false"); - Assert.IsTrue(expected != actual, $"expected({expected}) != actual({actual}) is not true"); - Assert.IsTrue(actual != expected, $"actual({actual}) != expected({expected}) is not true"); - } - - [TestMethod] - public void MergeCLR_CLR_Test() - { - // Arrange - var clr = SourceReference.ClrSource; - - // Act - var result = SourceReference.Merge(clr, clr); - - // Assert - AssertExactCompare(SourceReference.ClrSource, result); - } - - [TestMethod] - public void MergeCLR_NonCLR_Test() - { - // Arrange - var clr = SourceReference.ClrSource; - var nonClr = new SourceReference(1, 2, 3, 4); - - // Act - var result = SourceReference.Merge(clr, nonClr); - - // Assert - AssertExactCompare(nonClr, result); - } - - [TestMethod] - public void MergeNonClr_CLR_Test() - { - // Arrange - var nonClr = new SourceReference(1, 2, 3, 4); - var clr = SourceReference.ClrSource; - - // Act - var result = SourceReference.Merge(nonClr, clr); - - // Assert - AssertExactCompare(nonClr, result); - } - - [TestMethod] - public void MergeTwoSameRow_Test() - { - // Arrange - var value1 = new SourceReference(1, 1, 0, 1); - var value2 = new SourceReference(1, 1, 3, 4); - var expected = new SourceReference(1, 1, 0, 4); - - // Act - var result = SourceReference.Merge(value1, value2); - - // Assert - AssertExactCompare(expected, result); - } - - [TestMethod] - public void MergeTwoSameRowInverse_Test() - { - // Arrange - var value1 = new SourceReference(1, 1, 3, 4); - var value2 = new SourceReference(1, 1, 0, 1); - var expected = new SourceReference(1, 1, 0, 4); - - // Act - var result = SourceReference.Merge(value1, value2); - - // Assert - AssertExactCompare(expected, result); - } - - [TestMethod] - public void MergeTwoDifferentRowsInverse_Test() - { - // Arrange - var value1 = new SourceReference(1, 1, 0, 1); - var value2 = new SourceReference(2, 2, 3, 4); - var expected = new SourceReference(1, 2, 0, 4); - - // Act - var result = SourceReference.Merge(value1, value2); - - // Assert - AssertExactCompare(expected, result); - } - - [TestMethod] - public void MergeTwoDifferentRowsFallingEndColumn_Test() - { - // Arrange - var value1 = new SourceReference(1, 1, 3, 4); - var value2 = new SourceReference(2, 2, 0, 1); - var expected = new SourceReference(1, 2, 3, 1); - - // Act - var result = SourceReference.Merge(value1, value2); - - // Assert - AssertExactCompare(expected, result); - } - - [TestMethod] - public void MergeTwoInverseRowOrder_Test() - { - // Arrange - var value1 = new SourceReference(2, 2, 3, 4); - var value2 = new SourceReference(1, 1, 0, 1); - var expected = new SourceReference(1, 2, 0, 4); - - // Act - var result = SourceReference.Merge(value1, value2); - - // Assert - AssertExactCompare(expected, result); - } - - [TestMethod] - public void MergeMany_Test() - { - // Arrange - var value1 = new SourceReference(1, 1, 5, 9); - var value2 = new SourceReference(2, 2, 3, 3); - var value3 = new SourceReference(5, 6, 10, 12); - var value4 = new SourceReference(4, 9, 0, 1); - var expected = new SourceReference(1, 9, 5, 1); - - // Act - var result = SourceReference.Merge(value1, value2, value3, value4); - - // Assert - AssertExactCompare(expected, result); - } - - [TestMethod] - public void MergeEmptyList_Test() - { - // Arrange - void Action() - { - SourceReference.Merge(); - } - - // Act + Assert - Assert.ThrowsException((Action) Action); - } - - [TestMethod] - public void MergeNull_Test() - { - // Arrange - void Action() - { - SourceReference.Merge(null); - } - - // Act + Assert - Assert.ThrowsException((Action) Action); - } - - [TestMethod] - public void CompareEqualsCLR_CLR_Test() - { - // Arrange - var value1 = SourceReference.ClrSource; - var value2 = SourceReference.ClrSource; - - // Act + Assert - AssertEquals(value1, value2); - } - - [TestMethod] - public void CompareNotEqualsNonCLR_CLR_Test() - { - // Arrange - var value1 = new SourceReference(1, 1, 5, 9); - var value2 = SourceReference.ClrSource; - - // Act + Assert - AssertNotEquals(value1, value2); - } - - [TestMethod] - public void CompareNotEqualsNonCLR_NonCLR_Test() - { - // Arrange - var value1 = new SourceReference(1, 1, 5, 9); - var value2 = new SourceReference(2, 2, 3, 3); - - // Act + Assert - AssertNotEquals(value1, value2); - } - - [TestMethod] - public void CompareEqualsNonCLR_NonCLR_Test() - { - // Arrange - var value1 = new SourceReference(1, 1, 5, 9); - var value2 = new SourceReference(1, 1, 5, 9); - - // Act + Assert - AssertEquals(value1, value2); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Entities/ProcessState.cs b/src/Mellis.Core/Entities/ProcessState.cs deleted file mode 100644 index 3864c1a..0000000 --- a/src/Mellis.Core/Entities/ProcessState.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Mellis.Core.Entities -{ - public enum ProcessState - { - /// - /// Interpreter has just been initialized and not yet executed its first instruction. - /// - NotStarted, - - /// - /// Execution is in the middle of the interpreters instructions. - /// - Running, - - /// - /// Interpreter has paused in anticipation of a yielded function return. - /// - Yielded, - - /// - /// Exception was thrown from last instruction. - /// - Error, - - /// - /// End of instructions - /// - Ended - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Entities/SourceReference.cs b/src/Mellis.Core/Entities/SourceReference.cs deleted file mode 100644 index 927dcc6..0000000 --- a/src/Mellis.Core/Entities/SourceReference.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; - -namespace Mellis.Core.Entities -{ - public struct SourceReference : IEquatable - { - /// - /// Gets a source reference from the Common Language Runtime. - /// - public bool IsFromClr { get; private set; } - - /// - /// Starting row in code. 1..n, inclusive. - /// - public int FromRow { get; private set; } - - /// - /// Ending row in code. 1..n, inclusive. - /// Equal to start row property if same row. - /// - public int ToRow { get; private set; } - - /// - /// Starting column in code. 0..n-1, inclusive. - /// - public int FromColumn { get; private set; } - - /// - /// Ending column in code. 0..n-1, inclusive. - /// Equal to start column property if same column (and if single character). - /// Is 1 less than start column property if references zero characters. - /// - public int ToColumn { get; private set; } - - public static SourceReference ClrSource { get; } = new SourceReference - { - IsFromClr = true, - }; - - /// Starting row in code. 1..n, inclusive - /// - /// Ending row in code. 1..n, inclusive. - /// Equal to if same row. - /// - /// Starting column in code. 0..n-1, inclusive. - /// - /// Ending column in code. 0..n-1, inclusive. - /// Equal to if same column (and if single character). - /// Is 1 less than if references zero characters. - /// - public SourceReference( - int fromRow, - int toRow, - int fromColumn, - int toColumn) - { - IsFromClr = false; - FromRow = fromRow; - ToRow = toRow; - FromColumn = fromColumn; - ToColumn = toColumn; - } - - public SourceReference LastRow() - { - if (IsFromClr) - return ClrSource; - - if (FromRow == ToRow) - { - return this; - } - - return new SourceReference( - ToRow, ToRow, - 0, ToColumn - ); - } - - public static SourceReference Merge(SourceReference a, SourceReference b) - { - if (a.IsFromClr && b.IsFromClr) - return a; - - if (a.IsFromClr) - return b; - - if (b.IsFromClr) - return a; - - if (b.FromRow < a.FromRow) - { - a.FromRow = b.FromRow; - a.FromColumn = b.FromColumn; - } - else if (b.FromRow == a.FromRow && - b.FromColumn < a.FromColumn) - { - a.FromColumn = b.FromColumn; - } - - if (b.ToRow > a.ToRow) - { - a.ToRow = b.ToRow; - a.ToColumn = b.ToColumn; - } - else if (b.ToRow == a.ToRow && - b.ToColumn > a.ToColumn) - { - a.ToColumn = b.ToColumn; - } - - return a; - } - - public static SourceReference Merge(params SourceReference[] sourcesParams) - { - return Merge(sourcesEnumerable: sourcesParams); - } - - public static SourceReference Merge(IEnumerable sourcesEnumerable) - { - if (sourcesEnumerable == null) - throw new ArgumentNullException(nameof(sourcesEnumerable)); - - using (IEnumerator enumerator = sourcesEnumerable.GetEnumerator()) - { - if (!enumerator.MoveNext()) - { - throw new ArgumentException("SourceReference enumeration is empty.", nameof(sourcesEnumerable)); - } - - SourceReference value = enumerator.Current; - - while (enumerator.MoveNext()) - { - value = Merge(value, enumerator.Current); - } - - return value; - } - } - - public override string ToString() - { - if (IsFromClr) - return "$CLR"; - - if (FromRow == ToRow) - return $"ln{FromRow} col{FromColumn}-{ToColumn}"; - - return $"ln{FromRow} col{FromColumn}-ln{ToRow} col{ToColumn}"; - } - - public override bool Equals(object obj) - { - return obj is SourceReference source && Equals(source); - } - - public bool Equals(SourceReference other) - { - return IsFromClr == other.IsFromClr && - FromRow == other.FromRow && - ToRow == other.ToRow && - FromColumn == other.FromColumn && - ToColumn == other.ToColumn; - } - - public override int GetHashCode() - { - var hashCode = 57309968; - hashCode = hashCode * -1521134295 + IsFromClr.GetHashCode(); - hashCode = hashCode * -1521134295 + FromRow.GetHashCode(); - hashCode = hashCode * -1521134295 + ToRow.GetHashCode(); - hashCode = hashCode * -1521134295 + FromColumn.GetHashCode(); - hashCode = hashCode * -1521134295 + ToColumn.GetHashCode(); - return hashCode; - } - - public static bool operator ==(SourceReference reference1, SourceReference reference2) - { - return reference1.Equals(reference2); - } - - public static bool operator !=(SourceReference reference1, SourceReference reference2) - { - return !(reference1 == reference2); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Exceptions/InternalException.cs b/src/Mellis.Core/Exceptions/InternalException.cs deleted file mode 100644 index 967231f..0000000 --- a/src/Mellis.Core/Exceptions/InternalException.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace Mellis.Core.Exceptions -{ - public class InternalException : InterpreterLocalizedException - { - public InternalException(string localizeKey, string localizedMessageFormat, params object[] formatArgs) - : base(localizeKey, localizedMessageFormat, formatArgs) - { - } - - public InternalException(string localizeKey, string localizedMessage, Exception innerException) - : base(localizeKey, localizedMessage, innerException) - { - } - - public InternalException(string localizeKey, string localizedMessage) - : base(localizeKey, localizedMessage) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Exceptions/InterpreterException.cs b/src/Mellis.Core/Exceptions/InterpreterException.cs deleted file mode 100644 index 1f45fc7..0000000 --- a/src/Mellis.Core/Exceptions/InterpreterException.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace Mellis.Core.Exceptions -{ - /// - /// - /// Base class for all exceptions regarding the Zifro Compiler and it's plugins. - /// - public class InterpreterException : Exception - { - public InterpreterException(string message, Exception innerException) - : base(message, innerException) - { } - - public InterpreterException(string message) - : this(message, null) - { } - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Exceptions/InterpreterLocalizedException.cs b/src/Mellis.Core/Exceptions/InterpreterLocalizedException.cs deleted file mode 100644 index e08b836..0000000 --- a/src/Mellis.Core/Exceptions/InterpreterLocalizedException.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Mellis.Core.Exceptions -{ - public class InterpreterLocalizedException : InterpreterException - { - public string LocalizeKey { get; } - public object[] FormatArgs { get; } - - public InterpreterLocalizedException(string localizeKey, - string localizedMessage, Exception innerException) - : base( - localizedMessage, - innerException: innerException) - { - LocalizeKey = localizeKey; - FormatArgs = new object[0]; - } - - public InterpreterLocalizedException(string localizeKey, string localizedMessageFormat, - Exception innerException, params object[] formatArgs) - : this(localizeKey, - string.Format(localizedMessageFormat, formatArgs), - innerException: innerException) - { - FormatArgs = formatArgs; - } - - public InterpreterLocalizedException(string localizeKey, string localizedMessageFormat, - params object[] formatArgs) - : this(localizeKey, localizedMessageFormat, - innerException: null, - formatArgs: formatArgs) - { - } - - public InterpreterLocalizedException(string localizeKey, string localizedMessage) - : this(localizeKey, localizedMessage, - innerException: null) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Exceptions/RuntimeException.cs b/src/Mellis.Core/Exceptions/RuntimeException.cs deleted file mode 100644 index 10b8796..0000000 --- a/src/Mellis.Core/Exceptions/RuntimeException.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Mellis.Core.Exceptions -{ - /// - /// - /// Use this for exceptions that occur during runtime. From DivideByZero and TypeError to simple AssertionError. - /// - public class RuntimeException : InterpreterLocalizedException - { - public RuntimeException(string localizeKey, string localizedMessageFormat, params object[] formatArgs) - : base(localizeKey, localizedMessageFormat, formatArgs) - { - } - - public RuntimeException(string localizeKey, string localizedMessage, Exception innerException) - : base(localizeKey, localizedMessage, innerException) - { - } - - public RuntimeException(string localizeKey, string localizedMessage) - : base(localizeKey, localizedMessage) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Exceptions/SyntaxException.cs b/src/Mellis.Core/Exceptions/SyntaxException.cs deleted file mode 100644 index 9a78d72..0000000 --- a/src/Mellis.Core/Exceptions/SyntaxException.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Linq; -using Mellis.Core.Entities; - -namespace Mellis.Core.Exceptions -{ - /// - /// - /// Use this for compile-time exceptions based off the source code. - /// - public class SyntaxException : InterpreterLocalizedException - { - public SourceReference SourceReference { get; set; } - - /// - /// Creates a syntax exception based off the source code. - /// - /// The first 4 formatting values are dedicated from the source reference. - /// - /// {0} source start line - /// {1} source start column - /// {2} source end line - /// {3} source end column - /// - public SyntaxException(SourceReference source, string localizeKey, - string localizedMessageFormat, params object[] values) - : base(localizeKey, localizedMessageFormat, GetParams(source, values)) - { - SourceReference = source; - } - - protected static object[] GetParams(SourceReference source) - { - return new object[] - { - source.FromRow, source.FromColumn, - source.ToRow, source.ToColumn - }; - } - - protected static object[] GetParams(SourceReference source, object[] additional) - { - return GetParams(source).Concat(additional).ToArray(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Exceptions/SyntaxNotYetImplementedException.cs b/src/Mellis.Core/Exceptions/SyntaxNotYetImplementedException.cs deleted file mode 100644 index 7ea3287..0000000 --- a/src/Mellis.Core/Exceptions/SyntaxNotYetImplementedException.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Mellis.Core.Entities; -using Mellis.Core.Resources; - -namespace Mellis.Core.Exceptions -{ - /// - /// - /// Use this for compile-time exceptions where the used feature is not yet implemented by the compiler. - /// - public class SyntaxNotYetImplementedException : SyntaxException - { - public SyntaxNotYetImplementedException(SourceReference source) - : base(source, - nameof(Localized_Exceptions.Ex_Syntax_NotYetImplemented), - Localized_Exceptions.Ex_Syntax_NotYetImplemented) - { - } - - protected SyntaxNotYetImplementedException(SourceReference source, - string localizedKey, string localizedMessageFormat, params object[] values) - : base(source, localizedKey, localizedMessageFormat, values: values) - { - - } - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Interfaces/ICompiler.cs b/src/Mellis.Core/Interfaces/ICompiler.cs deleted file mode 100644 index 73a9c78..0000000 --- a/src/Mellis.Core/Interfaces/ICompiler.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Mellis.Core.Interfaces -{ - public interface ICompiler - { - IProcessor Compile(string code); - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Interfaces/IFunction.cs b/src/Mellis.Core/Interfaces/IFunction.cs deleted file mode 100644 index dac2bea..0000000 --- a/src/Mellis.Core/Interfaces/IFunction.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Mellis.Core.Entities; - -namespace Mellis.Core.Interfaces -{ - public interface IFunction - { - /// - /// The assigned processor environment. - /// Set by the processor when function is created via the processors factory. - /// - IProcessor Processor { set; } - - /// - /// Get the name of this function. - /// Used to identify it in the script environment and should therefore be a valid identifier. - /// Name rules: (letter | '_') (letter | '_' | number)* - /// Where number is 0-9 - /// Where letter is defined by all Unicode letter categories: UppercaseLetter, LowercaseLetter, TitlecaseLetter, ModifierLetter, and OtherLetter. - /// - string Name { get; } - - /// - /// Get the description of this function. Used primarily in exceptions. - /// - string Description { get; } - - /// - /// Get the source of where the variable was declared. - /// - SourceReference Source { get; } - - /// - /// Executed by the processor when the function is invoked in the script environment. - /// - IScriptType Invoke(IScriptType[] arguments); - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Interfaces/IProcessor.cs b/src/Mellis.Core/Interfaces/IProcessor.cs deleted file mode 100644 index d281602..0000000 --- a/src/Mellis.Core/Interfaces/IProcessor.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Core.Exceptions; - -namespace Mellis.Core.Interfaces -{ - public interface IProcessor - { - IScriptTypeFactory Factory { get; } - IScopeContext GlobalScope { get; } - IScopeContext CurrentScope { get; } - ProcessState State { get; } - SourceReference CurrentSource { get; } - - InterpreterException LastError { get; } - - void ContinueYieldedValue(IScriptType value); - void WalkLine(); - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Interfaces/IScopeContext.cs b/src/Mellis.Core/Interfaces/IScopeContext.cs deleted file mode 100644 index 7bdae59..0000000 --- a/src/Mellis.Core/Interfaces/IScopeContext.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace Mellis.Core.Interfaces -{ - public interface IScopeContext - { - IScopeContext ParentScope { get; } - IReadOnlyDictionary Variables { get; } - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Interfaces/IScriptType.cs b/src/Mellis.Core/Interfaces/IScriptType.cs deleted file mode 100644 index b87c47e..0000000 --- a/src/Mellis.Core/Interfaces/IScriptType.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; - -namespace Mellis.Core.Interfaces -{ - /// - /// Used for reference typed variables. - /// - public interface IScriptType - { - /// - /// The assigned processor environment. - /// - IProcessor Processor { get; } - - /// - /// (Lua, Python) type(this) - /// (JavaScript) typeof(this) - /// - IScriptType GetTypeDef(); - - /// - /// Name of this type. Used in error messages. - /// Should be localized to the current UI culture set via . - /// - string GetTypeName(); - - /// - /// For use in and & or operators, as well as if and while statements. - /// As and & or operators short-circuit depending on a values truthy'ness. - /// - bool IsTruthy(); - - /// - /// this(...) - /// - IScriptType Invoke(IScriptType[] arguments); - - /// - /// this[] - /// - IScriptType GetIndex(IScriptType index); - - /// - /// this[] = - /// - IScriptType SetIndex(IScriptType index, IScriptType value); - - /// - /// this. - /// - IScriptType GetProperty(string property); - - /// - /// this. = - /// - IScriptType SetProperty(string property, IScriptType value); - - /// - /// Try convert this value to it's CLR representation. - /// - bool TryConvert(out T value); - - /// - /// Try convert this value to it's CLR representation. - /// - bool TryConvert(Type type, out object value); - - #region Arithmetic operators - - /// - /// (Python, JavaScript) +this - /// - IScriptType ArithmeticUnaryPositive(); - - /// - /// -this - /// - IScriptType ArithmeticUnaryNegative(); - - /// - /// this + - /// - IScriptType ArithmeticAdd(IScriptType rhs); - - /// - /// this - - /// - IScriptType ArithmeticSubtract(IScriptType rhs); - - /// - /// this * - /// - IScriptType ArithmeticMultiply(IScriptType rhs); - - /// - /// this / - /// - IScriptType ArithmeticDivide(IScriptType rhs); - - /// - /// this % - /// - IScriptType ArithmeticModulus(IScriptType rhs); - - /// - /// (Python) this ** - /// (Lua) this ^ - /// - IScriptType ArithmeticExponent(IScriptType rhs); - - /// - /// (Python, Lua) this // - /// - IScriptType ArithmeticFloorDivide(IScriptType rhs); - - #endregion - - #region Comparison operators - - /// - /// this == - /// - IScriptType CompareEqual(IScriptType rhs); - - /// - /// (Lua) this ~= - /// (JavaScript, Python) this != - /// (Python) this <> - /// - IScriptType CompareNotEqual(IScriptType rhs); - - /// - /// this > - /// In Lua this is ignored. - /// Greater than is evaluated via reversing the order of - /// - IScriptType CompareGreaterThan(IScriptType rhs); - - /// - /// this >= - /// In Lua this is ignored. - /// Greater than is evaluated via reversing the order of - /// - IScriptType CompareGreaterThanOrEqual(IScriptType rhs); - - /// - /// this < - /// - IScriptType CompareLessThan(IScriptType rhs); - - /// - /// this <= - /// - IScriptType CompareLessThanOrEqual(IScriptType rhs); - - #endregion - - #region Bitwise operators - - /// - /// ~this - /// - IScriptType BinaryNot(); - - /// - /// this & - /// - IScriptType BinaryAnd(IScriptType rhs); - - /// - /// this | - /// - IScriptType BinaryOr(IScriptType rhs); - - /// - /// (Python, JavaScript) this ^ - /// (Lua) this ~ - /// - IScriptType BinaryXor(IScriptType rhs); - - /// - /// this << - /// - IScriptType BinaryLeftShift(IScriptType rhs); - - /// - /// this >> - /// - IScriptType BinaryRightShift(IScriptType rhs); - - #endregion - - #region Member operators - - /// - /// (JavaScript, Python) in this - /// - IScriptType MemberIn(IScriptType lhs); - - /// - /// (Python) not in this - /// - IScriptType MemberNotIn(IScriptType lhs); - - #endregion - - #region Identity operators - - /// - /// (Python) this is - /// (JavaScript) this instanceof - /// - IScriptType IdentityIs(IScriptType rhs); - - /// - /// (Python) this is not - /// - IScriptType IdentityIsNot(IScriptType rhs); - - #endregion - } -} diff --git a/src/Mellis.Core/Interfaces/IScriptTypeFactory.cs b/src/Mellis.Core/Interfaces/IScriptTypeFactory.cs deleted file mode 100644 index ae2d7c5..0000000 --- a/src/Mellis.Core/Interfaces/IScriptTypeFactory.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Mellis.Core.Interfaces -{ - public interface IScriptTypeFactory - { - /// - /// Gets a null/nil/None value from the current processor context. - /// - IScriptType Null { get; } - - /// - /// Gets a value representing the boolean TRUE value from the current processor context. - /// - IScriptType True { get; } - - /// - /// Gets a value representing the boolean FALSE value from the current processor context. - /// - IScriptType False { get; } - - /// - /// Creates a from type int (signed 32-bit integer) specific to the current context. - /// - IScriptType Create(int value); - - /// - /// Creates a from type long (signed 64-bit integer) specific to the current context. - /// - IScriptType Create(long value); - - /// - /// Creates a from type float (single-precision floating point number) specific to the current context. - /// - IScriptType Create(float value); - - /// - /// Creates a from type double (double-precision floating point number) specific to the current context. - /// - IScriptType Create(double value); - - /// - /// Creates a from type short (signed 16-bit integer) specific to the current context. - /// - IScriptType Create(short value); - - /// - /// Creates a from type byte (unsigned 8-bit integer) specific to the current context. - /// - IScriptType Create(byte value); - - /// - /// Creates a from type char (single UTF-16 character code) specific to the current context. - /// - IScriptType Create(char value); - - /// - /// Creates a from type string specific to the current context. - /// - IScriptType Create(string value); - - /// - /// Creates a from type bool specific to the current context. - /// You can also use the and properties. - /// - IScriptType Create(bool value); - - /// - /// Creates a from a list of specific to the current context. - /// - IScriptType Create(IList value); - - /// - /// Creates a from a dictionary of specific to the current context. - /// - IScriptType Create(IDictionary value); - - /// - /// Creates a from a function specific to the current context. - /// - IScriptType Create(IFunction value); - } -} \ No newline at end of file diff --git a/src/Mellis.Core/Mellis.Core.csproj b/src/Mellis.Core/Mellis.Core.csproj deleted file mode 100644 index d008272..0000000 --- a/src/Mellis.Core/Mellis.Core.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - netstandard2.0 - 7.2 - - - - - True - True - Localized_Exceptions.resx - - - - - - PublicResXFileCodeGenerator - Localized_Exceptions.Designer.cs - - - - diff --git a/src/Mellis.Core/Resources/Localized_Exceptions.Designer.cs b/src/Mellis.Core/Resources/Localized_Exceptions.Designer.cs deleted file mode 100644 index 79f473c..0000000 --- a/src/Mellis.Core/Resources/Localized_Exceptions.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Mellis.Core.Resources { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Localized_Exceptions { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Localized_Exceptions() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mellis.Core.Resources.Localized_Exceptions", typeof(Localized_Exceptions).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Denna funktion har tyvärr ej ännu blivit implementerad.. - /// - public static string Ex_Syntax_NotYetImplemented { - get { - return ResourceManager.GetString("Ex_Syntax_NotYetImplemented", resourceCulture); - } - } - } -} diff --git a/src/Mellis.Core/Resources/Localized_Exceptions.resx b/src/Mellis.Core/Resources/Localized_Exceptions.resx deleted file mode 100644 index 473361f..0000000 --- a/src/Mellis.Core/Resources/Localized_Exceptions.resx +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Denna funktion har tyvärr ej ännu blivit implementerad. - Default string for notyetimplemented features. Used where specific error string is not specified. -{0} source start line -{1} source start column -{2} source end line -{3} source end column - - \ No newline at end of file diff --git a/src/Mellis.Lang.Base.Tests/EntityBooleanBaseTests.cs b/src/Mellis.Lang.Base.Tests/EntityBooleanBaseTests.cs deleted file mode 100644 index 24e5cc7..0000000 --- a/src/Mellis.Lang.Base.Tests/EntityBooleanBaseTests.cs +++ /dev/null @@ -1,306 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Entities; -using Mellis.Lang.Base.Resources; - -namespace Mellis.Lang.Base.Tests -{ - [TestClass] - public class EntityBooleanBaseTests : BaseTestClass - { - private static string LocalizedBool(bool value) - { - return value - ? Localized_Base_Entities.Type_Boolean_True - : Localized_Base_Entities.Type_Boolean_False; - } - - [TestMethod] - public void BooleanAdditionTest() - { - // Arrange - BooleanBase a = GetBoolean(true); - BooleanBase b = GetBoolean(false); - object[] expectedFormatArgs = {a.Value, LocalizedBool(a.Value), b.GetTypeName()}; - - void Action() { a.ArithmeticAdd(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_AddInvalidOperation), - expectedFormatArgs); - } - - [TestMethod] - public void BooleanSubtractionTest() - { - // Arrange - BooleanBase a = GetBoolean(true); - BooleanBase b = GetBoolean(false); - object[] expectedFormatArgs = {a.Value, LocalizedBool(a.Value), b.GetTypeName()}; - - void Action() { a.ArithmeticSubtract(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_SubtractInvalidOperation), - expectedFormatArgs); - } - - [TestMethod] - public void BooleanMultiplicationTest() - { - // Arrange - BooleanBase a = GetBoolean(true); - BooleanBase b = GetBoolean(false); - object[] expectedFormatArgs = {a.Value, LocalizedBool(a.Value), b.GetTypeName()}; - - void Action() { a.ArithmeticMultiply(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_MultiplyInvalidOperation), - expectedFormatArgs); - } - - [TestMethod] - public void BooleanDivideTest() - { - // Arrange - BooleanBase a = GetBoolean(true); - BooleanBase b = GetBoolean(false); - object[] expectedFormatArgs = {a.Value, LocalizedBool(a.Value), b.GetTypeName()}; - - void Action() { a.ArithmeticDivide(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_DivideInvalidOperation), expectedFormatArgs); - } - - [TestMethod] - public void BooleanDivideByZeroTest() - { - // Arrange - BooleanBase a = GetBoolean(true); - BooleanBase b = GetBoolean(false); - object[] expectedFormatArgs = {a.Value, LocalizedBool(a.Value), b.GetTypeName()}; - - void Action() { a.ArithmeticDivide(b); } - - // Act + Assert - // Ensure not the "DIVIDE BY ZERO" error, just regular invalid-operation error - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_DivideInvalidOperation), expectedFormatArgs); - } - - [TestMethod] - public void BooleanIndexGet() - { - // Arrange - BooleanBase a = GetBoolean(true); - object[] expectedFormatArgs = {a.Value, LocalizedBool(a.Value)}; - - void Action() { a.GetIndex(null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_IndexGet), expectedFormatArgs); - } - - [TestMethod] - public void BooleanIndexSet() - { - // Arrange - BooleanBase a = GetBoolean(true); - object[] expectedFormatArgs = { a.Value, LocalizedBool(a.Value) }; - - void Action() { a.SetIndex(null, null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_IndexSet), expectedFormatArgs); - } - - [TestMethod] - public void BooleanPropertyGet() - { - // Arrange - BooleanBase a = GetBoolean(true); - const string property = "prop"; - object[] expectedFormatArgs = { a.Value, LocalizedBool(a.Value), property }; - - void Action() { a.GetProperty(property); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_PropertyGet), expectedFormatArgs); - } - - [TestMethod] - public void BooleanPropertySet() - { - // Arrange - BooleanBase a = GetBoolean(true); - const string property = "prop"; - object[] expectedFormatArgs = { a.Value, LocalizedBool(a.Value), property }; - - void Action() { a.SetProperty(property, null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_PropertySet), expectedFormatArgs); - } - - [TestMethod] - public void BooleanInvoke() - { - // Arrange - BooleanBase a = GetBoolean(true); - object[] expectedFormatArgs = { a.Value, LocalizedBool(a.Value) }; - - void Action() { a.Invoke(null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Boolean_Invoke), expectedFormatArgs); - } - - [TestMethod] - public void BooleanTryConvertValid() - { - // Arrange - BooleanBase a = GetBoolean(true); - - // Act - bool success = a.TryConvert(typeof(bool), out object result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual(true, result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [DataTestMethod] - [DataRow(true, typeof(uint))] - [DataRow(true, typeof(int))] - [DataRow(true, typeof(ulong))] - [DataRow(true, typeof(long))] - [DataRow(true, typeof(byte))] - [DataRow(true, typeof(sbyte))] - [DataRow(true, typeof(string))] - [DataRow(true, typeof(char))] - public void BooleanTryConvertInvalid(bool input, Type type) - { - // Arrange - BooleanBase a = GetBoolean(input); - - // Act - bool success = a.TryConvert(type, out object _); - - // Assert - Assert.IsFalse(success); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void BooleanTryConvertGenericValid() - { - // Arrange - BooleanBase a = GetBoolean(true); - - // Act - bool success = a.TryConvert(out bool result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual(true, result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void BooleanTryConvertGenericInvalid() - { - // Arrange - BooleanBase a = GetBoolean(true); - - // Act - bool success = a.TryConvert(out char _); - - // Assert - Assert.IsFalse(success); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [DataTestMethod] - [DataRow(true, false, false)] - [DataRow(false, true, false)] - [DataRow(false, false, true)] - [DataRow(true, true, true)] - public void BooleanCompareEqualBoolean(bool aVal, bool bVal, bool expected) - { - // Arrange - BooleanBase a = GetBoolean(aVal); - BooleanBase b = GetBoolean(bVal); - - // Act - IScriptType result = a.CompareEqual(b); - - // Assert - AssertArithmeticResult(result, a, b, expected); - } - - [DataTestMethod] - [DataRow("foo")] - [DataRow("True")] - [DataRow(1)] - [DataRow(0)] - [DataRow(1.5)] - public void BooleanCompareEqualOther(object value) - { - // Arrange - BooleanBase a = GetBoolean(true); - IScriptType b = GetValue(value); - const bool expected = false; - - // Act - IScriptType result = a.CompareEqual(b); - - // Assert - AssertArithmeticResult(result, a, b, expected); - } - - [DataTestMethod] - [DataRow(true, false, true)] - [DataRow(false, true, true)] - [DataRow(false, false, false)] - [DataRow(true, true, false)] - public void BooleanCompareNotEqualBoolean(bool aVal, bool bVal, bool expected) - { - // Arrange - BooleanBase a = GetBoolean(aVal); - BooleanBase b = GetBoolean(bVal); - - // Act - IScriptType result = a.CompareNotEqual(b); - - // Assert - AssertArithmeticResult(result, a, b, expected); - } - - [DataTestMethod] - [DataRow("foo")] - [DataRow("True")] - [DataRow(1)] - [DataRow(0)] - [DataRow(1.5)] - public void BooleanCompareNotEqualOther(object value) - { - // Arrange - BooleanBase a = GetBoolean(true); - IScriptType b = GetValue(value); - const bool expected = true; - - // Act - IScriptType result = a.CompareNotEqual(b); - - // Assert - AssertArithmeticResult(result, a, b, expected); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Base.Tests/EntityDoubleBaseTests.cs b/src/Mellis.Lang.Base.Tests/EntityDoubleBaseTests.cs deleted file mode 100644 index 1f4b2f7..0000000 --- a/src/Mellis.Lang.Base.Tests/EntityDoubleBaseTests.cs +++ /dev/null @@ -1,388 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Entities; -using Mellis.Lang.Base.Resources; - -namespace Mellis.Lang.Base.Tests -{ - [TestClass] - public class EntityDoubleBaseTests : BaseTestClass - { - [TestMethod] - public void DoubleAdditionWholeTest() - { - // Arrange - DoubleBase a = GetDouble(5); - DoubleBase b = GetDouble(10); - - // Act - IScriptType result = a.ArithmeticAdd(b); - - // Assert - AssertArithmeticResult(result, a, b, 15); - } - - [TestMethod] - public void DoubleAdditionFractionTest() - { - // Arrange - DoubleBase a = GetDouble(0.5); - DoubleBase b = GetDouble(1); - - // Act - IScriptType result = a.ArithmeticAdd(b); - - // Assert - AssertArithmeticResult(result, a, b, 1.5); - } - - [TestMethod] - public void DoubleAdditionIntegerTest() - { - // Arrange - DoubleBase a = GetDouble(0.5); - IntegerBase b = GetInteger(1); - - // Act - IScriptType result = a.ArithmeticAdd(b); - - // Assert - AssertArithmeticResult(result, a, b, 1.5); - } - - [TestMethod] - public void DoubleAdditionInvalidTest() - { - // Arrange - DoubleBase a = GetDouble(5); - StringBase b = GetString("foo"); - object[] expectedFormatArgs = {5d, b.GetTypeName()}; - void Action() { a.ArithmeticAdd(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Double_AddInvalidType), expectedFormatArgs); - } - - [TestMethod] - public void DoubleSubtractionWholeTest() - { - // Arrange - DoubleBase a = GetDouble(5); - DoubleBase b = GetDouble(10); - - // Act - IScriptType result = a.ArithmeticSubtract(b); - - // Assert - AssertArithmeticResult(result, a, b, -5); - } - - [TestMethod] - public void DoubleSubtractionFractionTest() - { - // Arrange - DoubleBase a = GetDouble(.5); - DoubleBase b = GetDouble(.1); - - // Act - IScriptType result = a.ArithmeticSubtract(b); - - // Assert - AssertArithmeticResult(result, a, b, .4); - } - - [TestMethod] - public void DoubleSubtractionIntegerTest() - { - // Arrange - DoubleBase a = GetDouble(5); - IntegerBase b = GetInteger(1); - - // Act - IScriptType result = a.ArithmeticSubtract(b); - - // Assert - AssertArithmeticResult(result, a, b, 4); - } - - [TestMethod] - public void DoubleSubtractionInvalidTest() - { - // Arrange - DoubleBase a = GetDouble(5); - StringBase b = GetString("foo"); - object[] expectedFormatArgs = {5d, b.GetTypeName()}; - void Action() { a.ArithmeticSubtract(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Double_SubtractInvalidType), expectedFormatArgs); - } - - [TestMethod] - public void DoubleMultiplicationTest() - { - // Arrange - DoubleBase a = GetDouble(5); - DoubleBase b = GetDouble(10); - - // Act - IScriptType result = a.ArithmeticMultiply(b); - - // Assert - AssertArithmeticResult(result, a, b, 50); - } - - [TestMethod] - public void DoubleMultiplicationIntegerTest() - { - // Arrange - DoubleBase a = GetDouble(5); - IntegerBase b = GetInteger(10); - - // Act - IScriptType result = a.ArithmeticMultiply(b); - - // Assert - AssertArithmeticResult(result, a, b, 50); - } - - [TestMethod] - public void DoubleMultiplicationInvalidTest() - { - // Arrange - DoubleBase a = GetDouble(5); - StringBase b = GetString("foo"); - object[] expectedFormatArgs = {5d, b.GetTypeName()}; - void Action() { a.ArithmeticMultiply(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Double_MultiplyInvalidType), expectedFormatArgs); - } - - [TestMethod] - public void DoubleDivideWholeTest() - { - // Arrange - DoubleBase a = GetDouble(50); - DoubleBase b = GetDouble(10); - - // Act - IScriptType result = a.ArithmeticDivide(b); - - // Assert - AssertArithmeticResult(result, a, b, 5); - } - - [TestMethod] - public void DoubleDivideFractionTest() - { - // Arrange - DoubleBase a = GetDouble(5); - DoubleBase b = GetDouble(10); - - // Act - IScriptType result = a.ArithmeticDivide(b); - - // Assert - AssertArithmeticResult(result, a, b, .5); - } - - [TestMethod] - public void DoubleDivideIntegerTest() - { - // Arrange - DoubleBase a = GetDouble(50); - IntegerBase b = GetInteger(10); - - // Act - IScriptType result = a.ArithmeticDivide(b); - - // Assert - AssertArithmeticResult(result, a, b, 5); - } - - [TestMethod] - public void DoubleDivideInvalidTest() - { - // Arrange - DoubleBase a = GetDouble(5); - StringBase b = GetString("foo"); - object[] expectedFormatArgs = {5d, b.GetTypeName()}; - void Action() { a.ArithmeticDivide(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Double_DivideInvalidType), expectedFormatArgs); - } - - [TestMethod] - public void DoubleDivideByZero() - { - // Arrange - DoubleBase a = GetDouble(5); - DoubleBase b = GetDouble(0); - object[] expectedFormatArgs = { }; - void Action() { a.ArithmeticDivide(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Math_DivideByZero), expectedFormatArgs); - } - - [TestMethod] - public void DoubleIndexGet() - { - // Arrange - DoubleBase a = GetDouble(5); - object[] expectedFormatArgs = {5d}; - - void Action() { a.GetIndex(null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Double_IndexGet), expectedFormatArgs); - } - - [TestMethod] - public void DoubleIndexSet() - { - // Arrange - DoubleBase a = GetDouble(5); - object[] expectedFormatArgs = {5d}; - - void Action() { a.SetIndex(null, null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Double_IndexSet), expectedFormatArgs); - } - - [TestMethod] - public void DoublePropertyGet() - { - // Arrange - DoubleBase a = GetDouble(5); - const string property = "prop"; - object[] expectedFormatArgs = {5d, property}; - - void Action() { a.GetProperty(property); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Double_PropertyGet), expectedFormatArgs); - } - - [TestMethod] - public void DoublePropertySet() - { - // Arrange - DoubleBase a = GetDouble(5); - const string property = "prop"; - object[] expectedFormatArgs = {5d, property}; - - void Action() { a.SetProperty(property, null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Double_PropertySet), expectedFormatArgs); - } - - [TestMethod] - public void DoubleInvoke() - { - // Arrange - DoubleBase a = GetDouble(5); - object[] expectedFormatArgs = {5d}; - - void Action() { a.Invoke(null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Double_Invoke), expectedFormatArgs); - } - - [DataTestMethod] - [DataRow(5D)] - public void DoubleTryConvertValid(object expected) - { - // Arrange - DoubleBase a = GetDouble(5); - Type type = expected.GetType(); - - // Act - bool success = a.TryConvert(type, out object result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual(expected, result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void DoubleTryConvertDecimal() - { - // Arrange - DoubleBase a = GetDouble(5); - - // Act - bool success = a.TryConvert(typeof(decimal), out object result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual(5m, result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [DataTestMethod] - [DataRow(typeof(float))] - [DataRow(typeof(int))] - [DataRow(typeof(uint))] - [DataRow(typeof(ulong))] - [DataRow(typeof(bool))] - [DataRow(typeof(byte))] - [DataRow(typeof(short))] - [DataRow(typeof(char))] - [DataRow(typeof(string))] - [DataRow(typeof(DateTime))] - public void DoubleTryConvertInvalid(Type type) - { - // Arrange - DoubleBase a = GetDouble(5); - - // Act - bool success = a.TryConvert(type, out object _); - - // Assert - Assert.IsFalse(success); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void DoubleTryConvertGenericValid() - { - // Arrange - DoubleBase a = GetDouble(5); - - // Act - bool success = a.TryConvert(out double result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual(5, result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void DoubleTryConvertGenericInvalid() - { - // Arrange - DoubleBase a = GetDouble(5); - - // Act - bool success = a.TryConvert(out string _); - - // Assert - Assert.IsFalse(success); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Base.Tests/EntityIntBaseTests.cs b/src/Mellis.Lang.Base.Tests/EntityIntBaseTests.cs deleted file mode 100644 index 13f84df..0000000 --- a/src/Mellis.Lang.Base.Tests/EntityIntBaseTests.cs +++ /dev/null @@ -1,348 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Entities; -using Mellis.Lang.Base.Resources; - -namespace Mellis.Lang.Base.Tests -{ - [TestClass] - public class EntityIntBaseTests : BaseTestClass - { - [TestMethod] - public void IntAdditionTest() - { - // Arrange - IntegerBase a = GetInteger(5); - IntegerBase b = GetInteger(10); - - // Act - IScriptType resultBase = a.ArithmeticAdd(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, 15); - } - - [TestMethod] - public void IntAdditionInvalidTest() - { - // Arrange - IntegerBase a = GetInteger(5); - StringBase b = GetString("foo"); - object[] expectedFormatArgs = {5, b.GetTypeName()}; - void Action() { a.ArithmeticAdd(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Int_AddInvalidType), expectedFormatArgs); - } - - [TestMethod] - public void IntSubtractionTest() - { - // Arrange - IntegerBase a = GetInteger(5); - IntegerBase b = GetInteger(10); - - // Act - IScriptType resultBase = a.ArithmeticSubtract(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, -5); - } - - [TestMethod] - public void IntSubtractionInvalidTest() - { - // Arrange - IntegerBase a = GetInteger(5); - StringBase b = GetString("foo"); - object[] expectedFormatArgs = {5, b.GetTypeName()}; - void Action() { a.ArithmeticSubtract(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Int_SubtractInvalidType), expectedFormatArgs); - } - - [TestMethod] - public void IntMultiplicationTest() - { - // Arrange - IntegerBase a = GetInteger(5); - IntegerBase b = GetInteger(10); - - // Act - IScriptType resultBase = a.ArithmeticMultiply(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, 50); - } - - [TestMethod] - public void IntMultiplicationInvalidTest() - { - // Arrange - IntegerBase a = GetInteger(5); - StringBase b = GetString("foo"); - object[] expectedFormatArgs = {5, b.GetTypeName()}; - void Action() { a.ArithmeticMultiply(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Int_MultiplyInvalidType), expectedFormatArgs); - } - - [TestMethod] - public void IntMultiplicationDoubleWholeTest() - { - // Arrange - IntegerBase a = GetInteger(5); - DoubleBase b = GetDouble(2); - - // Act - IScriptType resultBase = a.ArithmeticMultiply(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, 10); - } - - [TestMethod] - public void IntMultiplicationDoubleFractionTest() - { - // Arrange - IntegerBase a = GetInteger(5); - DoubleBase b = GetDouble(2.5); - const double expected = 5 * 2.5; - - // Act - IScriptType resultBase = a.ArithmeticMultiply(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, expected); - } - - [TestMethod] - public void IntDivideWholeTest() - { - // Arrange - IntegerBase a = GetInteger(50); - IntegerBase b = GetInteger(10); - - // Act - IScriptType resultBase = a.ArithmeticDivide(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, 5); - } - - [TestMethod] - public void IntDivideFractionTest() - { - // Arrange - IntegerBase a = GetInteger(5); - IntegerBase b = GetInteger(10); - - // Act - IScriptType resultBase = a.ArithmeticDivide(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, 0.5); - } - - [TestMethod] - public void IntDivideInvalidTest() - { - // Arrange - IntegerBase a = GetInteger(5); - StringBase b = GetString("foo"); - object[] expectedFormatArgs = {5, b.GetTypeName()}; - void Action() { a.ArithmeticDivide(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Int_DivideInvalidType), expectedFormatArgs); - } - - [TestMethod] - public void IntDivideByZero() - { - // Arrange - IntegerBase a = GetInteger(5); - IntegerBase b = GetInteger(0); - object[] expectedFormatArgs = { }; - void Action() { a.ArithmeticDivide(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Math_DivideByZero), expectedFormatArgs); - } - - [TestMethod] - public void IntDivideByDouble() - { - // Arrange - IntegerBase a = GetInteger(5); - DoubleBase b = GetDouble(2); - - // Act - IScriptType resultBase = a.ArithmeticDivide(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, 2.5); - } - - [TestMethod] - public void IntIndexGet() - { - // Arrange - IntegerBase a = GetInteger(5); - object[] expectedFormatArgs = {5}; - - void Action() { a.GetIndex(null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Int_IndexGet), expectedFormatArgs); - } - - [TestMethod] - public void IntIndexSet() - { - // Arrange - IntegerBase a = GetInteger(5); - object[] expectedFormatArgs = {5}; - - void Action() { a.SetIndex(null, null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Int_IndexSet), expectedFormatArgs); - } - - [TestMethod] - public void IntPropertyGet() - { - // Arrange - IntegerBase a = GetInteger(5); - const string property = "prop"; - object[] expectedFormatArgs = {5, property}; - - void Action() { a.GetProperty(property); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Int_PropertyGet), expectedFormatArgs); - } - - [TestMethod] - public void IntPropertySet() - { - // Arrange - IntegerBase a = GetInteger(5); - const string property = "prop"; - object[] expectedFormatArgs = {5, property}; - - void Action() { a.SetProperty(property, null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Int_PropertySet), expectedFormatArgs); - } - - [TestMethod] - public void IntInvoke() - { - // Arrange - IntegerBase a = GetInteger(5); - object[] expectedFormatArgs = {5}; - - void Action() { a.Invoke(null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_Int_Invoke), expectedFormatArgs); - } - - [DataTestMethod] - [DataRow(5)] - [DataRow(5L)] - [DataRow(5D)] - [DataRow(5F)] - public void IntTryConvertValid(object expected) - { - // Arrange - IntegerBase a = GetInteger(5); - Type type = expected.GetType(); - - // Act - bool success = a.TryConvert(type, out object result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual(expected, result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void IntTryConvertDecimal() - { - // Arrange - IntegerBase a = GetInteger(5); - - // Act - bool success = a.TryConvert(typeof(decimal), out object result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual(5m, result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [DataTestMethod] - [DataRow(typeof(uint))] - [DataRow(typeof(ulong))] - [DataRow(typeof(bool))] - [DataRow(typeof(byte))] - [DataRow(typeof(short))] - [DataRow(typeof(char))] - [DataRow(typeof(string))] - [DataRow(typeof(DateTime))] - public void IntTryConvertInvalid(Type type) - { - // Arrange - IntegerBase a = GetInteger(5); - - // Act - bool success = a.TryConvert(type, out object _); - - // Assert - Assert.IsFalse(success); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void IntTryConvertGenericValid() - { - // Arrange - IntegerBase a = GetInteger(5); - - // Act - bool success = a.TryConvert(out int result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual(5, result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void IntTryConvertGenericInvalid() - { - // Arrange - IntegerBase a = GetInteger(5); - - // Act - bool success = a.TryConvert(out string _); - - // Assert - Assert.IsFalse(success); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Base.Tests/EntityStringBaseTests.cs b/src/Mellis.Lang.Base.Tests/EntityStringBaseTests.cs deleted file mode 100644 index 1bc0f73..0000000 --- a/src/Mellis.Lang.Base.Tests/EntityStringBaseTests.cs +++ /dev/null @@ -1,282 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Entities; -using Mellis.Lang.Base.Resources; - -namespace Mellis.Lang.Base.Tests -{ - [TestClass] - public class EntityStringBaseTests : BaseTestClass - { - [TestMethod] - public void StringAdditionTest() - { - // Arrange - StringBase a = GetString("foo"); - StringBase b = GetString("bar"); - - // Act - IScriptType resultBase = a.ArithmeticAdd(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, "foobar"); - } - - [TestMethod] - public void StringAdditionEmptyTest() - { - // Arrange - StringBase a = GetString(""); - StringBase b = GetString(""); - - // Act - IScriptType resultBase = a.ArithmeticAdd(b); - - // Assert - AssertArithmeticResult(resultBase, a, b, ""); - } - - [TestMethod] - public void StringAdditionInvalidTest() - { - // Arrange - StringBase a = GetString("foo"); - IntegerBase b = GetInteger(5); - object[] expectedFormatArgs = { a.Value, a.Value.Length, b.GetTypeName() }; - - void Action() { a.ArithmeticAdd(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_AddInvalidType), expectedFormatArgs); - } - - [TestMethod] - public void StringSubtractionTest() - { - // Arrange - StringBase a = GetString("foo"); - StringBase b = GetString("bar"); - object[] expectedFormatArgs = { a.Value, a.Value.Length, b.GetTypeName() }; - - void Action() { a.ArithmeticSubtract(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_SubtractInvalidOperation), expectedFormatArgs); - } - - [TestMethod] - public void StringMultiplicationTest() - { - // Arrange - StringBase a = GetString("foo"); - StringBase b = GetString("bar"); - object[] expectedFormatArgs = { a.Value, a.Value.Length, b.GetTypeName() }; - - void Action() { a.ArithmeticMultiply(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_MultiplyInvalidOperation), expectedFormatArgs); - } - - [TestMethod] - public void StringDivideWholeTest() - { - // Arrange - StringBase a = GetString("foo"); - StringBase b = GetString("bar"); - object[] expectedFormatArgs = { a.Value, a.Value.Length, b.GetTypeName() }; - - void Action() { a.ArithmeticDivide(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_DivideInvalidOperation), expectedFormatArgs); - } - - [TestMethod] - public void StringDivideByZeroTest() - { - // Arrange - StringBase a = GetString("foo"); - IntegerBase b = GetInteger(0); - object[] expectedFormatArgs = { a.Value, a.Value.Length, b.GetTypeName() }; - - void Action() { a.ArithmeticDivide(b); } - - // Act + Assert - // Ensure not the "DIVIDE BY ZERO" error, just regular invalid-operation error - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_DivideInvalidOperation), expectedFormatArgs); - } - - [TestMethod] - public void StringIndexGetInteger() - { - // Arrange - StringBase a = GetString("foo"); - IntegerBase b = GetInteger(0); - - // Act - IScriptType result = a.GetIndex(b); - - // Assert - AssertArithmeticResult(result, a, b, "f"); - } - - [TestMethod] - public void StringIndexGetIntegerOutOfRange() - { - // Arrange - StringBase a = GetString("foo"); - IntegerBase b = GetInteger(10); - object[] expectedFormatArgs = { a.Value, a.Value.Length, b.Value }; - - void Action() { a.GetIndex(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_IndexGet_OutOfRange), expectedFormatArgs); - } - - [TestMethod] - public void StringIndexGetInvalid() - { - // Arrange - StringBase a = GetString("foo"); - StringBase b = GetString("a"); - object[] expectedFormatArgs = { a.Value, a.Value.Length, b.GetTypeName() }; - - void Action() { a.GetIndex(b); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_IndexGet_InvalidType), expectedFormatArgs); - } - - [TestMethod] - public void StringIndexSet() - { - // Arrange - StringBase a = GetString("foo"); - object[] expectedFormatArgs = { a.Value, a.Value.Length }; - - void Action() { a.SetIndex(null, null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_IndexSet), expectedFormatArgs); - } - - [TestMethod] - public void StringPropertyGet() - { - // Arrange - StringBase a = GetString("foo"); - const string property = "prop"; - object[] expectedFormatArgs = { a.Value, a.Value.Length, property }; - - void Action() { a.GetProperty(property); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_PropertyGet), expectedFormatArgs); - } - - [TestMethod] - public void StringPropertySet() - { - // Arrange - StringBase a = GetString("foo"); - const string property = "prop"; - object[] expectedFormatArgs = { a.Value, a.Value.Length, property }; - - void Action() { a.SetProperty(property, null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_PropertySet), expectedFormatArgs); - } - - [TestMethod] - public void StringInvoke() - { - // Arrange - StringBase a = GetString("foo"); - object[] expectedFormatArgs = { a.Value, a.Value.Length }; - - void Action() { a.Invoke(null); } - - // Act + Assert - AssertThrow(Action, nameof(Localized_Base_Entities.Ex_String_Invoke), expectedFormatArgs); - } - - [DataTestMethod] - [DataRow("foo", "foo")] - [DataRow("f", "f")] - [DataRow("", "")] - [DataRow("f", 'f')] // char - [DataRow("foo", 'f')] // char - public void StringTryConvertValid(string input, object expected) - { - // Arrange - StringBase a = GetString(input); - Type type = expected.GetType(); - - // Act - bool success = a.TryConvert(type, out object result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual(expected, result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [DataTestMethod] - [DataRow("foo", typeof(uint))] - [DataRow("foo", typeof(int))] - [DataRow("foo", typeof(ulong))] - [DataRow("foo", typeof(long))] - [DataRow("foo", typeof(float))] - [DataRow("foo", typeof(double))] - [DataRow("", typeof(char))] // because its empty - public void StringTryConvertInvalid(string input, Type type) - { - // Arrange - StringBase a = GetString(input); - - // Act - bool success = a.TryConvert(type, out object _); - - // Assert - Assert.IsFalse(success); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void StringTryConvertGenericValid() - { - // Arrange - StringBase a = GetString("foo"); - - // Act - bool success = a.TryConvert(out string result); - - // Assert - Assert.IsTrue(success); - Assert.AreEqual("foo", result); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void StringTryConvertGenericInvalid() - { - // Arrange - StringBase a = GetString(""); - - // Act - bool success = a.TryConvert(out char _); - - // Assert - Assert.IsFalse(success); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Base.Tests/Mellis.Lang.Base.Tests.csproj b/src/Mellis.Lang.Base.Tests/Mellis.Lang.Base.Tests.csproj deleted file mode 100644 index 2389506..0000000 --- a/src/Mellis.Lang.Base.Tests/Mellis.Lang.Base.Tests.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - netcoreapp2.1 - - false - - 7.2 - - - - - - - - - - - - - - - diff --git a/src/Mellis.Lang.Base.Tests/_BaseTestClass.cs b/src/Mellis.Lang.Base.Tests/_BaseTestClass.cs deleted file mode 100644 index f34850c..0000000 --- a/src/Mellis.Lang.Base.Tests/_BaseTestClass.cs +++ /dev/null @@ -1,158 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Entities; - -namespace Mellis.Lang.Base.Tests -{ - public class BaseTestClass - { - protected Mock processorMock; - protected Mock factoryMock; - - [TestInitialize] - public void TestInitialize() - { - processorMock = new Mock(); - factoryMock = new Mock(); - - processorMock.SetupGet(o => o.Factory).Returns(factoryMock.Object); - factoryMock.Setup(o => o.Create(It.IsAny())) - .Returns(GetInteger); - factoryMock.Setup(o => o.Create(It.IsAny())) - .Returns(GetDouble); - factoryMock.Setup(o => o.Create(It.IsAny())) - .Returns(GetString); - factoryMock.Setup(o => o.Create(It.IsAny())) - .Returns(c => GetString(c.ToString())); - - factoryMock.SetupGet(o => o.True) - .Returns(GetBoolean(true)); - factoryMock.SetupGet(o => o.False) - .Returns(GetBoolean(false)); - } - - protected IntegerBase GetInteger(int value) - { - return GetValue(value); - } - - protected DoubleBase GetDouble(double value) - { - return GetValue(value); - } - - protected StringBase GetString(string value) - { - return GetValue(value); - } - - protected BooleanBase GetBoolean(bool value) - { - return GetValue(value); - } - - private TScriptType GetValue(TValue value) - where TScriptType : class, IScriptType - { - return new Mock(processorMock.Object, value) {CallBase = true}.Object; - } - - protected IScriptType GetValue(object value) - { - switch (value) - { - case int i: - return GetInteger(i); - case double d: - return GetDouble(d); - case string s: - return GetString(s); - case bool b: - return GetBoolean(b); - default: - throw new NotSupportedException(); - } - } - - protected void AssertArithmeticResult(IScriptType resultBase, IScriptType lhs, IScriptType rhs, - object expected) - where T : IScriptType - { - Assert.IsNotNull(resultBase); - Assert.IsInstanceOfType(resultBase, typeof(T)); - var result = (T)resultBase; - Assert.IsNotNull(result); - Assert.AreNotSame(lhs, result); - Assert.AreNotSame(rhs, result); - - AssertAreEqual(expected, result); - - processorMock.VerifyGet(o => o.Factory, Times.Once); - processorMock.VerifyNoOtherCalls(); - - switch (expected) - { - case int i: - factoryMock.Verify(o => o.Create(i), - Times.Once); - break; - - case double d: - factoryMock.Verify(o => o.Create(It.Is(v => Math.Abs(v - d) < 1e-10)), - Times.Once); - break; - - case string s: - factoryMock.Verify(o => o.Create(It.Is(v => v == s)), - Times.Exactly(s.Length == 1 ? 0 : 1)); - factoryMock.Verify(o => o.Create(It.Is(v => v.ToString() == s)), - Times.Exactly(s.Length == 1 ? 1 : 0)); - break; - - case bool b when b: - factoryMock.VerifyGet(o => o.True, Times.Once); - break; - - case bool b when !b: - factoryMock.VerifyGet(o => o.False, Times.Once); - break; - } - - factoryMock.VerifyNoOtherCalls(); - } - - protected void AssertThrow(Action action, string localizationKey, object[] expectedFormatArgs) - { - var ex = Assert.ThrowsException(action); - Assert.IsNotNull(ex); - Assert.AreEqual(ex.LocalizeKey, localizationKey); - CollectionAssert.AreEqual(ex.FormatArgs, expectedFormatArgs); - processorMock.VerifyNoOtherCalls(); - factoryMock.VerifyNoOtherCalls(); - } - - protected void AssertAreEqual(object expected, IScriptType actual) - { - switch (actual) - { - case DoubleBase d when expected is double e: - Assert.AreEqual(e, d.Value, 1e-10); - break; - case IntegerBase i: - Assert.AreEqual(expected, i.Value); - break; - case StringBase s: - Assert.AreEqual(expected, s.Value); - break; - case BooleanBase s: - Assert.AreEqual(expected, s.Value); - break; - default: - throw new NotSupportedException(); - } - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Base/Entities/BooleanBase.cs b/src/Mellis.Lang.Base/Entities/BooleanBase.cs deleted file mode 100644 index f8ec26d..0000000 --- a/src/Mellis.Lang.Base/Entities/BooleanBase.cs +++ /dev/null @@ -1,297 +0,0 @@ -using System; -using System.Linq; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Resources; - -namespace Mellis.Lang.Base.Entities -{ - /// - /// - /// Basic functionality of a double value. - /// - public abstract class BooleanBase : IScriptType - { - /// - public abstract IScriptType GetTypeDef(); - - /// - public IProcessor Processor { get; } - - public bool Value { get; } - - protected BooleanBase(IProcessor processor, bool value) - { - Processor = processor; - Value = value; - } - - /// - public virtual string GetTypeName() - { - return Localized_Base_Entities.Type_Boolean_Name; - } - - protected object[] GetErrorArgs(params object[] additional) - { - return GetErrorArgs().Concat(additional).ToArray(); - } - - protected object[] GetErrorArgs() - { - return new object[] - { - Value, - GetLocalizedString() - }; - } - - public string GetLocalizedString() - { - return Value - ? Localized_Base_Entities.Type_Boolean_True - : Localized_Base_Entities.Type_Boolean_False; - } - - /// - public virtual bool IsTruthy() - { - return Value; - } - - /// - public virtual IScriptType Invoke(IScriptType[] arguments) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Boolean_Invoke), - Localized_Base_Entities.Ex_Boolean_Invoke, - formatArgs: GetErrorArgs()); - } - - /// - public virtual IScriptType GetIndex(IScriptType index) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Boolean_IndexGet), - Localized_Base_Entities.Ex_Boolean_IndexGet, - formatArgs: GetErrorArgs()); - } - - /// - public virtual IScriptType SetIndex(IScriptType index, IScriptType value) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Boolean_IndexSet), - Localized_Base_Entities.Ex_Boolean_IndexSet, - formatArgs: GetErrorArgs()); - } - - /// - public virtual IScriptType GetProperty(string property) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Boolean_PropertyGet), - Localized_Base_Entities.Ex_Boolean_PropertyGet, - formatArgs: GetErrorArgs(property)); - } - - /// - public virtual IScriptType SetProperty(string property, IScriptType value) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Boolean_PropertySet), - Localized_Base_Entities.Ex_Boolean_PropertySet, - formatArgs: GetErrorArgs(property)); - } - - /// - public bool TryConvert(out T value) - { - if (TryConvert(typeof(T), out object boxed)) - { - value = (T) boxed; - return true; - } - - value = default; - return false; - } - - /// - public bool TryConvert(Type type, out object value) - { - if (type == typeof(bool)) - { - value = Value; - return true; - } - - value = default; - return false; - } - - /// - public IScriptType ArithmeticUnaryPositive() - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticUnaryNegative() - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticAdd(IScriptType rhs) - { - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Boolean_AddInvalidOperation), - Localized_Base_Entities.Ex_Boolean_AddInvalidOperation, - formatArgs: GetErrorArgs(rhs.GetTypeName())); - } - - /// - public IScriptType ArithmeticSubtract(IScriptType rhs) - { - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Boolean_SubtractInvalidOperation), - Localized_Base_Entities.Ex_Boolean_SubtractInvalidOperation, - formatArgs: GetErrorArgs(rhs.GetTypeName())); - } - - /// - public IScriptType ArithmeticMultiply(IScriptType rhs) - { - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Boolean_MultiplyInvalidOperation), - Localized_Base_Entities.Ex_Boolean_MultiplyInvalidOperation, - formatArgs: GetErrorArgs(rhs.GetTypeName())); - } - - /// - public IScriptType ArithmeticDivide(IScriptType rhs) - { - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Boolean_DivideInvalidOperation), - Localized_Base_Entities.Ex_Boolean_DivideInvalidOperation, - formatArgs: GetErrorArgs(rhs.GetTypeName())); - } - - /// - public IScriptType ArithmeticModulus(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticExponent(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticFloorDivide(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareEqual(IScriptType rhs) - { - if (rhs is BooleanBase b && b.Value == Value) - return Processor.Factory.True; - - return Processor.Factory.False; - } - - /// - public IScriptType CompareNotEqual(IScriptType rhs) - { - if (rhs is BooleanBase b && b.Value == Value) - return Processor.Factory.False; - - return Processor.Factory.True; - } - - /// - public IScriptType CompareGreaterThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareGreaterThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareLessThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareLessThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryNot() - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryAnd(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryOr(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryXor(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryLeftShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryRightShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType MemberIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType MemberNotIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType IdentityIs(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType IdentityIsNot(IScriptType rhs) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Base/Entities/DoubleBase.cs b/src/Mellis.Lang.Base/Entities/DoubleBase.cs deleted file mode 100644 index 67aa470..0000000 --- a/src/Mellis.Lang.Base/Entities/DoubleBase.cs +++ /dev/null @@ -1,323 +0,0 @@ -using System; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Resources; -using Mellis.Tools.Extensions; - -namespace Mellis.Lang.Base.Entities -{ - /// - /// - /// Basic functionality of a double value. - /// - public abstract class DoubleBase : IScriptType - { - /// - public abstract IScriptType GetTypeDef(); - - /// - public IProcessor Processor { get; } - - public double Value { get; } - - protected DoubleBase(IProcessor processor, double value) - { - Processor = processor; - Value = value; - } - - /// - public virtual string GetTypeName() - { - return Localized_Base_Entities.Type_Double_Name; - } - - /// - public virtual IScriptType Invoke(IScriptType[] arguments) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Double_Invoke), - Localized_Base_Entities.Ex_Double_Invoke, - Value); - } - - /// - public virtual IScriptType GetIndex(IScriptType index) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Double_IndexGet), - Localized_Base_Entities.Ex_Double_IndexGet, - Value); - } - - /// - public virtual IScriptType SetIndex(IScriptType index, IScriptType value) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Double_IndexSet), - Localized_Base_Entities.Ex_Double_IndexSet, - Value); - } - - /// - public virtual IScriptType GetProperty(string property) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Double_PropertyGet), - Localized_Base_Entities.Ex_Double_PropertyGet, - Value, - property); - } - - /// - public virtual IScriptType SetProperty(string property, IScriptType value) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Double_PropertySet), - Localized_Base_Entities.Ex_Double_PropertySet, - Value, - property); - } - - /// - public bool TryConvert(out T value) - { - if (TryConvert(typeof(T), out object boxed)) - { - value = (T) boxed; - return true; - } - - value = default; - return false; - } - - /// - public bool TryConvert(Type type, out object value) - { - if (type == typeof(double)) - { - value = (double) Value; - return true; - } - - if (type == typeof(decimal)) - { - value = (decimal) Value; - return true; - } - - value = default; - return false; - } - - /// - public virtual bool IsTruthy() - { - return !Value.Equals(0d); - } - - /// - public IScriptType ArithmeticUnaryPositive() - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticUnaryNegative() - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticAdd(IScriptType rhs) - { - switch (rhs) - { - case DoubleBase rhsDouble: - return Processor.Factory.CreateAppropriate(Value + rhsDouble.Value); - - case IntegerBase rhsInt: - return Processor.Factory.CreateAppropriate(Value + rhsInt.Value); - - default: - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Double_AddInvalidType), - Localized_Base_Entities.Ex_Double_AddInvalidType, - Value, rhs.GetTypeName()); - } - } - - /// - public IScriptType ArithmeticSubtract(IScriptType rhs) - { - switch (rhs) - { - case DoubleBase rhsDouble: - return Processor.Factory.CreateAppropriate(Value - rhsDouble.Value); - - case IntegerBase rhsInt: - return Processor.Factory.CreateAppropriate(Value - rhsInt.Value); - - default: - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Double_SubtractInvalidType), - Localized_Base_Entities.Ex_Double_SubtractInvalidType, - Value, rhs.GetTypeName()); - } - } - - /// - public IScriptType ArithmeticMultiply(IScriptType rhs) - { - switch (rhs) - { - case IntegerBase rhsInt: - return Processor.Factory.CreateAppropriate(Value * rhsInt.Value); - - case DoubleBase rhsDouble: - return Processor.Factory.CreateAppropriate(Value * rhsDouble.Value); - - default: - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Double_MultiplyInvalidType), - Localized_Base_Entities.Ex_Double_MultiplyInvalidType, - Value, rhs.GetTypeName()); - } - } - - /// - public IScriptType ArithmeticDivide(IScriptType rhs) - { - switch (rhs) - { - case IntegerBase rhsInteger when rhsInteger.Value.Equals(0): - case DoubleBase rhsDouble when rhsDouble.Value.Equals(0d): - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Math_DivideByZero), - Localized_Base_Entities.Ex_Math_DivideByZero); - - case DoubleBase rhsDouble: - return Processor.Factory.CreateAppropriate(Value / rhsDouble.Value); - - case IntegerBase rhsInt: - return Processor.Factory.CreateAppropriate(Value / rhsInt.Value); - - default: - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Double_DivideInvalidType), - Localized_Base_Entities.Ex_Double_DivideInvalidType, - Value, rhs.GetTypeName()); - } - } - - /// - public IScriptType ArithmeticModulus(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticExponent(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticFloorDivide(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareNotEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareGreaterThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareGreaterThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareLessThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareLessThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryNot() - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryAnd(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryOr(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryXor(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryLeftShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryRightShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType MemberIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType MemberNotIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType IdentityIs(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType IdentityIsNot(IScriptType rhs) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Base/Entities/IntegerBase.cs b/src/Mellis.Lang.Base/Entities/IntegerBase.cs deleted file mode 100644 index 230715c..0000000 --- a/src/Mellis.Lang.Base/Entities/IntegerBase.cs +++ /dev/null @@ -1,332 +0,0 @@ -using System; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Resources; -using Mellis.Tools.Extensions; - -namespace Mellis.Lang.Base.Entities -{ - /// - /// - /// Basic functionality of an integer value. - /// - public abstract class IntegerBase : IScriptType - { - /// - public abstract IScriptType GetTypeDef(); - - /// - public IProcessor Processor { get; } - - public int Value { get; } - - protected IntegerBase(IProcessor processor, int value) - { - Processor = processor; - Value = value; - } - - /// - public virtual string GetTypeName() - { - return Localized_Base_Entities.Type_Int_Name; - } - - public virtual bool IsTruthy() - { - return !Value.Equals(0); - } - - /// - public virtual IScriptType Invoke(IScriptType[] arguments) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Int_Invoke), - Localized_Base_Entities.Ex_Int_Invoke, - Value); - } - - /// - public virtual IScriptType GetIndex(IScriptType index) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Int_IndexGet), - Localized_Base_Entities.Ex_Int_IndexGet, - Value); - } - - /// - public virtual IScriptType SetIndex(IScriptType index, IScriptType value) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Int_IndexSet), - Localized_Base_Entities.Ex_Int_IndexSet, - Value); - } - - /// - public virtual IScriptType GetProperty(string property) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Int_PropertyGet), - Localized_Base_Entities.Ex_Int_PropertyGet, - Value, - property); - } - - /// - public virtual IScriptType SetProperty(string property, IScriptType value) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_Int_PropertySet), - Localized_Base_Entities.Ex_Int_PropertySet, - Value, - property); - } - - /// - public bool TryConvert(out T value) - { - if (TryConvert(typeof(T), out object boxed)) - { - value = (T) boxed; - return true; - } - - value = default; - return false; - } - - /// - public bool TryConvert(Type type, out object value) - { - if (type == typeof(int)) - { - value = Value; - return true; - } - - if (type == typeof(long)) - { - value = (long) Value; - return true; - } - - if (type == typeof(double)) - { - value = (double) Value; - return true; - } - - if (type == typeof(float)) - { - value = (float) Value; - return true; - } - - if (type == typeof(decimal)) - { - value = (decimal) Value; - return true; - } - - value = default; - return false; - } - - /// - public IScriptType ArithmeticUnaryPositive() - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticUnaryNegative() - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticAdd(IScriptType rhs) - { - switch (rhs) - { - case IntegerBase rhsInt: - return Processor.Factory.Create(Value + rhsInt.Value); - default: - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Int_AddInvalidType), - Localized_Base_Entities.Ex_Int_AddInvalidType, - Value, rhs?.GetTypeName() ?? "null"); - } - } - - /// - public IScriptType ArithmeticSubtract(IScriptType rhs) - { - switch (rhs) - { - case IntegerBase rhsInt: - return Processor.Factory.Create(Value - rhsInt.Value); - default: - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Int_SubtractInvalidType), - Localized_Base_Entities.Ex_Int_SubtractInvalidType, - Value, rhs?.GetTypeName() ?? "null"); - } - } - - /// - public IScriptType ArithmeticMultiply(IScriptType rhs) - { - switch (rhs) - { - case IntegerBase rhsInt: - return Processor.Factory.Create(Value * rhsInt.Value); - - case DoubleBase rhsDouble: - return Processor.Factory.CreateAppropriate(Value * rhsDouble.Value); - - default: - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Int_MultiplyInvalidType), - Localized_Base_Entities.Ex_Int_MultiplyInvalidType, - Value, rhs?.GetTypeName() ?? "null"); - } - } - - /// - public IScriptType ArithmeticDivide(IScriptType rhs) - { - switch (rhs) - { - case IntegerBase rhsInt when rhsInt.Value.Equals(0): - case DoubleBase rhsDouble when rhsDouble.Value.Equals(0): - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Math_DivideByZero), - Localized_Base_Entities.Ex_Math_DivideByZero); - - case IntegerBase rhsInt: - return Processor.Factory.CreateAppropriate(Value / (double) rhsInt.Value); - - case DoubleBase rhsDouble: - return Processor.Factory.CreateAppropriate(Value / rhsDouble.Value); - - default: - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_Int_DivideInvalidType), - Localized_Base_Entities.Ex_Int_DivideInvalidType, - Value, rhs?.GetTypeName() ?? "null"); - } - } - - /// - public IScriptType ArithmeticModulus(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticExponent(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticFloorDivide(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareNotEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareGreaterThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareGreaterThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareLessThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareLessThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryNot() - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryAnd(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryOr(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryXor(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryLeftShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryRightShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType MemberIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType MemberNotIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType IdentityIs(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType IdentityIsNot(IScriptType rhs) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Base/Entities/StringBase.cs b/src/Mellis.Lang.Base/Entities/StringBase.cs deleted file mode 100644 index de97a71..0000000 --- a/src/Mellis.Lang.Base/Entities/StringBase.cs +++ /dev/null @@ -1,305 +0,0 @@ -using System; -using System.Linq; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Resources; - -namespace Mellis.Lang.Base.Entities -{ - /// - /// - /// Basic functionality of a string value. - /// - public abstract class StringBase : IScriptType - { - /// - public abstract IScriptType GetTypeDef(); - - /// - public IProcessor Processor { get; } - - public string Value { get; } - - protected StringBase(IProcessor processor, string value) - { - Processor = processor; - Value = value ?? string.Empty; - } - - /// - public virtual string GetTypeName() - { - return Localized_Base_Entities.Type_String_Name; - } - - public virtual bool IsTruthy() - { - return !string.IsNullOrEmpty(Value); - } - - protected object[] GetErrorArgs(params object[] additional) - { - return GetErrorArgs().Concat(additional).ToArray(); - } - - protected object[] GetErrorArgs() - { - return new object[] {Value, Value.Length}; - } - - /// - public virtual IScriptType Invoke(IScriptType[] arguments) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_String_Invoke), - Localized_Base_Entities.Ex_String_Invoke, - formatArgs: GetErrorArgs()); - } - - /// - public virtual IScriptType GetIndex(IScriptType index) - { - switch (index) - { - case IntegerBase indexInteger when indexInteger.Value >= 0 && - indexInteger.Value < Value.Length: - return Processor.Factory.Create(Value[indexInteger.Value]); - - case IntegerBase indexInteger: - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_String_IndexGet_OutOfRange), - Localized_Base_Entities.Ex_String_IndexGet_OutOfRange, - formatArgs: GetErrorArgs(indexInteger.Value)); - - default: - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_String_IndexGet_InvalidType), - Localized_Base_Entities.Ex_String_IndexGet_InvalidType, - formatArgs: GetErrorArgs(index.GetTypeName())); - } - } - - /// - public virtual IScriptType SetIndex(IScriptType index, IScriptType value) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_String_IndexSet), - Localized_Base_Entities.Ex_String_IndexSet, - formatArgs: GetErrorArgs()); - } - - /// - public virtual IScriptType GetProperty(string property) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_String_PropertyGet), - Localized_Base_Entities.Ex_String_PropertyGet, - formatArgs: GetErrorArgs(property)); - } - - /// - public virtual IScriptType SetProperty(string property, IScriptType value) - { - throw new RuntimeException( - nameof(Localized_Base_Entities.Ex_String_PropertySet), - Localized_Base_Entities.Ex_String_PropertySet, - formatArgs: GetErrorArgs(property)); - } - - /// - public bool TryConvert(out T value) - { - if (TryConvert(typeof(T), out object boxed)) - { - value = (T) boxed; - return true; - } - - value = default; - return false; - } - - /// - public virtual bool TryConvert(Type type, out object value) - { - if (type == typeof(string)) - { - value = Value; - return true; - } - - if (type == typeof(char) && Value?.Length >= 1) - { - value = Value[0]; - return true; - } - - value = default; - return false; - } - - /// - public IScriptType ArithmeticUnaryPositive() - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticUnaryNegative() - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticAdd(IScriptType rhs) - { - switch (rhs) - { - case StringBase rhsString: - return Processor.Factory.Create(Value + rhsString.Value); - default: - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_String_AddInvalidType), - Localized_Base_Entities.Ex_String_AddInvalidType, - formatArgs: GetErrorArgs(rhs.GetTypeName())); - } - } - - /// - public IScriptType ArithmeticSubtract(IScriptType rhs) - { - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_String_SubtractInvalidOperation), - Localized_Base_Entities.Ex_String_SubtractInvalidOperation, - formatArgs: GetErrorArgs(rhs.GetTypeName())); - } - - /// - public IScriptType ArithmeticMultiply(IScriptType rhs) - { - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_String_MultiplyInvalidOperation), - Localized_Base_Entities.Ex_String_MultiplyInvalidOperation, - formatArgs: GetErrorArgs(rhs.GetTypeName())); - } - - /// - public IScriptType ArithmeticDivide(IScriptType rhs) - { - throw new RuntimeException(nameof(Localized_Base_Entities.Ex_String_DivideInvalidOperation), - Localized_Base_Entities.Ex_String_DivideInvalidOperation, - formatArgs: GetErrorArgs(rhs.GetTypeName())); - } - - /// - public IScriptType ArithmeticModulus(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticExponent(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType ArithmeticFloorDivide(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareNotEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareGreaterThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareGreaterThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareLessThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType CompareLessThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryNot() - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryAnd(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryOr(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryXor(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryLeftShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType BinaryRightShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType MemberIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType MemberNotIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType IdentityIs(IScriptType rhs) - { - throw new NotImplementedException(); - } - - /// - public IScriptType IdentityIsNot(IScriptType rhs) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Base/Mellis.Lang.Base.csproj b/src/Mellis.Lang.Base/Mellis.Lang.Base.csproj deleted file mode 100644 index ba8c693..0000000 --- a/src/Mellis.Lang.Base/Mellis.Lang.Base.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - netstandard2.0 - latest - - - - - - - - - - Localized_Base_Entities.resx - True - True - - - - - - Localized_Base_Entities.Designer.cs - PublicResXFileCodeGenerator - - - - diff --git a/src/Mellis.Lang.Base/Resources/Localized_Base_Entities.Designer.cs b/src/Mellis.Lang.Base/Resources/Localized_Base_Entities.Designer.cs deleted file mode 100644 index fc62e15..0000000 --- a/src/Mellis.Lang.Base/Resources/Localized_Base_Entities.Designer.cs +++ /dev/null @@ -1,459 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Mellis.Lang.Base.Resources { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Localized_Base_Entities { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Localized_Base_Entities() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mellis.Lang.Base.Resources.Localized_Base_Entities", typeof(Localized_Base_Entities).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Ett {1} boolean värde kan inte adderas med ett annat värde.. - /// - public static string Ex_Boolean_AddInvalidOperation { - get { - return ResourceManager.GetString("Ex_Boolean_AddInvalidOperation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ett {1} boolean värde kan inte divideras med ett annat värde.. - /// - public static string Ex_Boolean_DivideInvalidOperation { - get { - return ResourceManager.GetString("Ex_Boolean_DivideInvalidOperation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ett {1} boolean värde kan inte indexeras.. - /// - public static string Ex_Boolean_IndexGet { - get { - return ResourceManager.GetString("Ex_Boolean_IndexGet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Det går inte att sätta inre värde på ett {1} boolean värde genom indexering.. - /// - public static string Ex_Boolean_IndexSet { - get { - return ResourceManager.GetString("Ex_Boolean_IndexSet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ett {1} boolean värde kan inte köras som en funktion.. - /// - public static string Ex_Boolean_Invoke { - get { - return ResourceManager.GetString("Ex_Boolean_Invoke", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ett {1} boolean värde kan inte multipliseras med ett annat värde.. - /// - public static string Ex_Boolean_MultiplyInvalidOperation { - get { - return ResourceManager.GetString("Ex_Boolean_MultiplyInvalidOperation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att läsa egenskapen '{2}' från ett {1} boolean värde. Booleans har inga egenskaper.. - /// - public static string Ex_Boolean_PropertyGet { - get { - return ResourceManager.GetString("Ex_Boolean_PropertyGet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Det går inte att ändra egenskapen '{2}' på ett {1} boolean värde. Booleans har inga egenskaper.. - /// - public static string Ex_Boolean_PropertySet { - get { - return ResourceManager.GetString("Ex_Boolean_PropertySet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ett {1} boolean värde kan inte subtraheras med ett annat värde.. - /// - public static string Ex_Boolean_SubtractInvalidOperation { - get { - return ResourceManager.GetString("Ex_Boolean_SubtractInvalidOperation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att addera decimaltalet '{0}' med värde av typen '{1}'.. - /// - public static string Ex_Double_AddInvalidType { - get { - return ResourceManager.GetString("Ex_Double_AddInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att dividera decimaltalet '{0}' med värde av typen '{1}'.. - /// - public static string Ex_Double_DivideInvalidType { - get { - return ResourceManager.GetString("Ex_Double_DivideInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ett decimaltal kan inte indexeras.. - /// - public static string Ex_Double_IndexGet { - get { - return ResourceManager.GetString("Ex_Double_IndexGet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Det går inte att sätta inre värde på ett decimaltal genom indexering.. - /// - public static string Ex_Double_IndexSet { - get { - return ResourceManager.GetString("Ex_Double_IndexSet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ett decimaltal kan inte köras som en funktion.. - /// - public static string Ex_Double_Invoke { - get { - return ResourceManager.GetString("Ex_Double_Invoke", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att multiplisera decimaltalet '{0}' med värde av typen '{1}'.. - /// - public static string Ex_Double_MultiplyInvalidType { - get { - return ResourceManager.GetString("Ex_Double_MultiplyInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att läsa egenskapen '{1}' från decimaltalet. Decimaltal har inga egenskaper.. - /// - public static string Ex_Double_PropertyGet { - get { - return ResourceManager.GetString("Ex_Double_PropertyGet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Det går inte att ändra egenskapen '{1}' på decimaltalet. Decimaltal har inga egenskaper.. - /// - public static string Ex_Double_PropertySet { - get { - return ResourceManager.GetString("Ex_Double_PropertySet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att subtrahera decimaltalet '{0}' med värde av typen '{1}'.. - /// - public static string Ex_Double_SubtractInvalidType { - get { - return ResourceManager.GetString("Ex_Double_SubtractInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att addera heltalet '{0}' med värde av typen '{1}'.. - /// - public static string Ex_Int_AddInvalidType { - get { - return ResourceManager.GetString("Ex_Int_AddInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att dividera heltalet '{0}' med värde av typen '{1}'.. - /// - public static string Ex_Int_DivideInvalidType { - get { - return ResourceManager.GetString("Ex_Int_DivideInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ett heltal kan inte indexeras.. - /// - public static string Ex_Int_IndexGet { - get { - return ResourceManager.GetString("Ex_Int_IndexGet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Det går inte att sätta inre värde på ett heltal genom indexering.. - /// - public static string Ex_Int_IndexSet { - get { - return ResourceManager.GetString("Ex_Int_IndexSet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ett heltalsvärde kan inte köras som en funktion.. - /// - public static string Ex_Int_Invoke { - get { - return ResourceManager.GetString("Ex_Int_Invoke", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att multiplisera heltalet '{0}' med värde av typen '{1}'.. - /// - public static string Ex_Int_MultiplyInvalidType { - get { - return ResourceManager.GetString("Ex_Int_MultiplyInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att läsa egenskapen '{1}' från heltalet. Heltal har inga egenskaper.. - /// - public static string Ex_Int_PropertyGet { - get { - return ResourceManager.GetString("Ex_Int_PropertyGet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Det går inte att ändra egenskapen '{1}' på ett heltal. Heltal har inga egenskaper.. - /// - public static string Ex_Int_PropertySet { - get { - return ResourceManager.GetString("Ex_Int_PropertySet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att subtrahera heltalet '{0}' med värde av typen '{1}'.. - /// - public static string Ex_Int_SubtractInvalidType { - get { - return ResourceManager.GetString("Ex_Int_SubtractInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Du får inte dela ett tal på noll!. - /// - public static string Ex_Math_DivideByZero { - get { - return ResourceManager.GetString("Ex_Math_DivideByZero", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att addera din textsträng på {1} karaktärer med värde av typen '{2}'.. - /// - public static string Ex_String_AddInvalidType { - get { - return ResourceManager.GetString("Ex_String_AddInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to En textsträng kan inte divideras med ett annat värde.. - /// - public static string Ex_String_DivideInvalidOperation { - get { - return ResourceManager.GetString("Ex_String_DivideInvalidOperation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to En textsträng kan endast indexeras av heltal, inte av typen '{2}'.. - /// - public static string Ex_String_IndexGet_InvalidType { - get { - return ResourceManager.GetString("Ex_String_IndexGet_InvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att läsa bokstaven på plats '{2}' då den är utanför textsträngens längd ({1}).. - /// - public static string Ex_String_IndexGet_OutOfRange { - get { - return ResourceManager.GetString("Ex_String_IndexGet_OutOfRange", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Det går inte att ändra enstaka bokstäver i en textsträng genom indexering.. - /// - public static string Ex_String_IndexSet { - get { - return ResourceManager.GetString("Ex_String_IndexSet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to En textsträng kan inte köras som en funktion.. - /// - public static string Ex_String_Invoke { - get { - return ResourceManager.GetString("Ex_String_Invoke", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to En textsträng kan inte multipliseras med ett annat värde.. - /// - public static string Ex_String_MultiplyInvalidOperation { - get { - return ResourceManager.GetString("Ex_String_MultiplyInvalidOperation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gick inte att läsa egenskapen '{2}' från textsträngen.. - /// - public static string Ex_String_PropertyGet { - get { - return ResourceManager.GetString("Ex_String_PropertyGet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Det går inte att ändra egenskapen '{2}' på en textsträng.. - /// - public static string Ex_String_PropertySet { - get { - return ResourceManager.GetString("Ex_String_PropertySet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to En textsträng kan inte subtraheras med ett annat värde.. - /// - public static string Ex_String_SubtractInvalidOperation { - get { - return ResourceManager.GetString("Ex_String_SubtractInvalidOperation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to falskt. - /// - public static string Type_Boolean_False { - get { - return ResourceManager.GetString("Type_Boolean_False", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to boolean. - /// - public static string Type_Boolean_Name { - get { - return ResourceManager.GetString("Type_Boolean_Name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to sant. - /// - public static string Type_Boolean_True { - get { - return ResourceManager.GetString("Type_Boolean_True", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to decimaltal. - /// - public static string Type_Double_Name { - get { - return ResourceManager.GetString("Type_Double_Name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to heltal. - /// - public static string Type_Int_Name { - get { - return ResourceManager.GetString("Type_Int_Name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to textsträng. - /// - public static string Type_String_Name { - get { - return ResourceManager.GetString("Type_String_Name", resourceCulture); - } - } - } -} diff --git a/src/Mellis.Lang.Base/Resources/Localized_Base_Entities.resx b/src/Mellis.Lang.Base/Resources/Localized_Base_Entities.resx deleted file mode 100644 index 0d2c013..0000000 --- a/src/Mellis.Lang.Base/Resources/Localized_Base_Entities.resx +++ /dev/null @@ -1,296 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Du får inte dela ett tal på noll! - myNumber / 0 - - - Ett heltal kan inte indexeras. - myInt[x]; value of int={0} - - - Det går inte att sätta inre värde på ett heltal genom indexering. - myInt[x] = value; value of int={0} - - - Ett heltalsvärde kan inte köras som en funktion. - myInt(); value of int={0} - - - Gick inte att läsa egenskapen '{1}' från heltalet. Heltal har inga egenskaper. - myInt.prop; value of int={0}, property name={1} - - - Det går inte att ändra egenskapen '{1}' på ett heltal. Heltal har inga egenskaper. - myInt.prop = value; value of int={0}, property name={1} - - - Ett decimaltal kan inte indexeras. - myDouble[x]; value of double={0} - - - Det går inte att sätta inre värde på ett decimaltal genom indexering. - myDouble[x] = value; value of double={0} - - - Ett decimaltal kan inte köras som en funktion. - myDouble(); value of double={0} - - - Gick inte att läsa egenskapen '{1}' från decimaltalet. Decimaltal har inga egenskaper. - myDouble.prop; value of double={0}, property name={1} - - - Det går inte att ändra egenskapen '{1}' på decimaltalet. Decimaltal har inga egenskaper. - myDouble.prop = value; value of double={0}, property name={1} - - - En textsträng kan endast indexeras av heltal, inte av typen '{2}'. - myStr[x]; value of str={0}, length of str={1}, index type str={1} - - - Gick inte att läsa bokstaven på plats '{2}' då den är utanför textsträngens längd ({1}). - myStr[x]; value of str={0}, length of str={1}, int index={2} - - - Det går inte att ändra enstaka bokstäver i en textsträng genom indexering. - myStr[x] = value; value of str={0}, length of str={1} - - - En textsträng kan inte köras som en funktion. - myStr(); value of str={0}, length of str={1} - - - Gick inte att läsa egenskapen '{2}' från textsträngen. - myStr.prop; value of str={0}, length of str={1}, property name={2} - - - Det går inte att ändra egenskapen '{2}' på en textsträng. - myStr.prop = value; value of str={0}, length of str={1}, property name={2} - - - Gick inte att dividera heltalet '{0}' med värde av typen '{1}'. - myInt / value; value of int={0}, other type name={1} - - - Gick inte att addera heltalet '{0}' med värde av typen '{1}'. - myInt + value; value of int={0}, other type name={1} - - - Gick inte att multiplisera heltalet '{0}' med värde av typen '{1}'. - myInt * value; value of int={0}, other type name={1} - - - Gick inte att subtrahera heltalet '{0}' med värde av typen '{1}'. - myInt - value; value of int={0}, other type name={1} - - - Gick inte att dividera decimaltalet '{0}' med värde av typen '{1}'. - myDouble / value; value of double={0}, other type name={1} - - - Gick inte att addera decimaltalet '{0}' med värde av typen '{1}'. - myDouble + value; value of double={0}, other type name={1} - - - Gick inte att multiplisera decimaltalet '{0}' med värde av typen '{1}'. - myDouble * value; value of double={0}, other type name={1} - - - Gick inte att subtrahera decimaltalet '{0}' med värde av typen '{1}'. - myDouble - value; value of double={0}, other type name={1} - - - Gick inte att addera din textsträng på {1} karaktärer med värde av typen '{2}'. - myStr + value; value of str={0}, length of str={1}, other type name={2} - - - En textsträng kan inte divideras med ett annat värde. - myStr / value; value of str={0}, length of str={1}, other type name={2} - - - En textsträng kan inte multipliseras med ett annat värde. - myStr * value; value of str={0}, length of str={1}, other type name={2} - - - En textsträng kan inte subtraheras med ett annat värde. - myStr - value; value of str={0}, length of str={1}, other type name={2} - - - Ett {1} boolean värde kan inte indexeras. - myBool[x]; value of bool={0}, Type_Boolean_True/False={1} - - - Det går inte att sätta inre värde på ett {1} boolean värde genom indexering. - myBool[x] = value; value of bool={0}, Type_Boolean_True/False={1} - - - Ett {1} boolean värde kan inte köras som en funktion. - myBool(); value of bool={0}, Type_Boolean_True/False={1} - - - Gick inte att läsa egenskapen '{2}' från ett {1} boolean värde. Booleans har inga egenskaper. - myBool.prop; value of bool={0}, Type_Boolean_True/False={1}, property name={2} - - - Det går inte att ändra egenskapen '{2}' på ett {1} boolean värde. Booleans har inga egenskaper. - myBool.prop = value; value of bool={0}, Type_Boolean_True/False={1}, property name={2} - - - Ett {1} boolean värde kan inte adderas med ett annat värde. - myBool + value; value of bool={0}, Type_Boolean_True/False={1}, other type name={2} - - - Ett {1} boolean värde kan inte divideras med ett annat värde. - myBool / value; value of bool={0}, Type_Boolean_True/False={1}, other type name={2} - - - Ett {1} boolean värde kan inte multipliseras med ett annat värde. - myBool * value; value of bool={0}, Type_Boolean_True/False={1}, other type name={2} - - - Ett {1} boolean värde kan inte subtraheras med ett annat värde. - myBool - value; value of bool={0}, Type_Boolean_True/False={1}, other type name={2} - - - decimaltal - Name of double type. Used in some errors, ex: Ex_String_AddInvalidType - - - heltal - Name of integer type. Used in some errors, ex: Ex_String_AddInvalidType - - - textsträng - Name of string type. Used in some errors, ex: Ex_Int_AddInvalidType - - - boolean - Name of boolean type. Used in some errors, ex: Ex_Int_AddInvalidType - - - sant - True. Used in some errors, ex: Ex_Boolean_IndexGet - - - falskt - False. Used in some errors, ex: Ex_Boolean_IndexGet - - \ No newline at end of file diff --git a/src/Mellis.Lang.Python3.Tests/Compiler/CompileExpressionTests.cs b/src/Mellis.Lang.Python3.Tests/Compiler/CompileExpressionTests.cs deleted file mode 100644 index fb85b8b..0000000 --- a/src/Mellis.Lang.Python3.Tests/Compiler/CompileExpressionTests.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Instructions; -using Mellis.Lang.Python3.Syntax; -using Mellis.Lang.Python3.Syntax.Operators; -using Mellis.Lang.Python3.Syntax.Operators.Arithmetics; -using Mellis.Lang.Python3.Syntax.Operators.Binaries; -using Mellis.Lang.Python3.Syntax.Operators.Comparisons; -using Mellis.Lang.Python3.Syntax.Operators.Logicals; -using Mellis.Lang.Python3.Tests.TestingOps; - -namespace Mellis.Lang.Python3.Tests.Compiler -{ - [TestClass] - public class CompileExpressionTests - { - [DataTestMethod] - [DataRow(typeof(ArithmeticAdd), OperatorCode.AAdd, DisplayName = "comp op +")] - [DataRow(typeof(ArithmeticSubtract), OperatorCode.ASub, DisplayName = "comp op -")] - [DataRow(typeof(ArithmeticMultiply), OperatorCode.AMul, DisplayName = "comp op *")] - [DataRow(typeof(ArithmeticDivide), OperatorCode.ADiv, DisplayName = "comp op /")] - [DataRow(typeof(ArithmeticFloor), OperatorCode.AFlr, DisplayName = "comp op //")] - [DataRow(typeof(ArithmeticModulus), OperatorCode.AMod, DisplayName = "comp op %")] - [DataRow(typeof(ArithmeticPower), OperatorCode.APow, DisplayName = "comp op **")] - [DataRow(typeof(BinaryAnd), OperatorCode.BAnd, DisplayName = "comp op a&b")] - [DataRow(typeof(BinaryLeftShift), OperatorCode.BLsh, DisplayName = "comp op a< exprLhsMock, - out NopOp exprLhsOp); - - compiler.CreateAndSetup( - out Mock exprRhsMock, - out NopOp exprRhsOp); - - var opNode = (BinaryOperator) Activator.CreateInstance(operatorType, - exprLhsMock.Object, exprRhsMock.Object); - - // Act - opNode.Compile(compiler); - - // Assert - Assert.That.IsBinaryOpCode(expectedCode, compiler, index: 2); - Assert.AreEqual(3, compiler.Count); - Assert.AreSame(exprLhsOp, compiler[0], "compiler[0] was not exprLhsOp"); - Assert.AreSame(exprRhsOp, compiler[1], "compiler[1] was not exprRhsOp"); - - exprLhsMock.Verify(o => o.Compile(compiler), Times.Once); - exprRhsMock.Verify(o => o.Compile(compiler), Times.Once); - } - - [DataTestMethod] - [DataRow(typeof(ArithmeticNegative), OperatorCode.ANeg, DisplayName = "comp op +b")] - [DataRow(typeof(ArithmeticPositive), OperatorCode.APos, DisplayName = "comp op -b")] - [DataRow(typeof(BinaryNot), OperatorCode.BNot, DisplayName = "comp op ~b")] - [DataRow(typeof(LogicalNot), OperatorCode.LNot, DisplayName = "comp op !b")] - public void CompileUnaryTests(Type operatorType, OperatorCode expectedCode) - { - // Arrange - var compiler = new PyCompiler(); - - compiler.CreateAndSetup( - out Mock exprMock, - out NopOp exprOp); - - var opNode = (UnaryOperator) Activator.CreateInstance(operatorType, - SourceReference.ClrSource, - exprMock.Object); - - // Act - opNode.Compile(compiler); - - // Assert - Assert.That.IsBinaryOpCode(expectedCode, compiler, index: 1); - Assert.AreEqual(2, compiler.Count); - Assert.AreSame(exprOp, compiler[0]); - - exprMock.Verify(o => o.Compile(compiler), Times.Once); - } - - [TestMethod] - public void IdentifierTest() - { - // Arrange - var compiler = new PyCompiler(); - - var identifier = new Identifier(SourceReference.ClrSource, "foo"); - - // Act - identifier.Compile(compiler); - - // Assert - var varGet = Assert.That.IsOpCode(compiler, 0); - Assert.AreEqual(1, compiler.Count); - Assert.AreEqual("foo", varGet.Identifier); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3.Tests/Compiler/CompileStatementTests.cs b/src/Mellis.Lang.Python3.Tests/Compiler/CompileStatementTests.cs deleted file mode 100644 index 704e025..0000000 --- a/src/Mellis.Lang.Python3.Tests/Compiler/CompileStatementTests.cs +++ /dev/null @@ -1,397 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Mellis.Core.Entities; -using Mellis.Core.Exceptions; -using Mellis.Lang.Python3.Instructions; -using Mellis.Lang.Python3.Syntax; -using Mellis.Lang.Python3.Syntax.Literals; -using Mellis.Lang.Python3.Syntax.Statements; -using Mellis.Lang.Python3.Tests.TestingOps; - -namespace Mellis.Lang.Python3.Tests.Compiler -{ - [TestClass] - public class CompileStatementTests - { - [TestMethod] - public void CompileAssignmentOnIdentifierTest() - { - // Arrange - const string identifier = "foo"; - var compiler = new PyCompiler(); - - var idLhsMock = new Mock(SourceReference.ClrSource, identifier); - - compiler.CreateAndSetup( - out Mock exprRhsMock, - out NopOp exprRhsOp); - - var stmt = new Assignment(SourceReference.ClrSource, - leftOperand: idLhsMock.Object, - rightOperand: exprRhsMock.Object); - - // Act - stmt.Compile(compiler); - - // Assert - var setOpCode = Assert.That.IsOpCode(compiler, index: 1); - Assert.AreEqual(identifier, setOpCode.Identifier); - Assert.AreEqual(2, compiler.Count); - Assert.AreSame(exprRhsOp, compiler[0], "compiler[0] was not exprRhsOp"); - - idLhsMock.Verify(o => o.Compile(compiler), Times.Never); - exprRhsMock.Verify(o => o.Compile(compiler), Times.Once); - } - - [TestMethod] - public void CompileAssignmentOnLiteralTest() - { - // Arrange - var compiler = new PyCompiler(); - - var source = new SourceReference(3,5,5,1); - var intLhsMock = new Mock(source, 5); - - compiler.CreateAndSetup( - out Mock exprRhsMock, - out NopOp exprRhsOp); - - var stmt = new Assignment(SourceReference.ClrSource, - leftOperand: intLhsMock.Object, - rightOperand: exprRhsMock.Object); - - void Action() - { - stmt.Compile(compiler); - } - - // Act - var ex = Assert.ThrowsException((Action) Action); - - // Assert - Assert.That.ErrorNotYetImplFormatArgs(ex, source); - - intLhsMock.Verify(o => o.Compile(compiler), Times.Never); - exprRhsMock.Verify(o => o.Compile(compiler), Times.Never); - } - - [TestMethod] - public void Compile_If_Test() - { - // Arrange - var compiler = new PyCompiler(); - - compiler.CreateAndSetup( - out Mock testMock, - out NopOp testOp); - - compiler.CreateAndSetup( - out Mock suiteMock, - out NopOp suiteOp); - - var stmt = new IfStatement(SourceReference.ClrSource, - testMock.Object, suiteMock.Object - ); - - // Act - stmt.Compile(compiler); - - // Assert - // test - Assert.That.IsExpectedOpCode(compiler, 0, testOp); - var jumpToEnd = Assert.That.IsOpCode(compiler, 1); - // suite - Assert.That.IsExpectedOpCode(compiler, 2, suiteOp); - // end - var labelEnd = Assert.That.IsOpCode diff --git a/src/Mellis.Lang.Python3/Properties/AssemblyInfo.cs b/src/Mellis.Lang.Python3/Properties/AssemblyInfo.cs deleted file mode 100644 index 31ce7f1..0000000 --- a/src/Mellis.Lang.Python3/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -/* - * AssemblyInfo is automatically generated. - * This only appends additional info - */ - -using System.Runtime.CompilerServices; - -[assembly:InternalsVisibleTo("Mellis.Lang.Python3.Tests")] \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/PyCompiler.cs b/src/Mellis.Lang.Python3/PyCompiler.cs deleted file mode 100644 index aff3e9a..0000000 --- a/src/Mellis.Lang.Python3/PyCompiler.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using Antlr4.Runtime; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Extensions; -using Mellis.Lang.Python3.Grammar; -using Mellis.Lang.Python3.Interfaces; -using Mellis.Lang.Python3.Syntax; - -namespace Mellis.Lang.Python3 -{ - public class PyCompiler : ICompiler, IReadOnlyList - { - private readonly List _opCodes; - - public PyCompiler() - { - _opCodes = new List(1024); - } - - public PyCompiler(params IOpCode[] opCodes) - { - _opCodes = new List(opCodes); - } - - public IProcessor Compile(string code) - { - var inputStream = new AntlrInputStream(code + "\n"); - - var lexer = new Python3Lexer(inputStream); - var tokenStream = new CommonTokenStream(lexer); - var parser = new Python3Parser(tokenStream); - - var visitor = new SyntaxConstructor(); - - SyntaxNode result = visitor.VisitFile_input(parser.file_input()); - - if (result is null) - return new PyProcessor(); - - var statement = result.AsTypeOrThrow(); - statement.Compile(this); - - return new PyProcessor(_opCodes.ToArray()); - } - - public void Push(IOpCode opCode) - { - if (opCode is null) - throw new ArgumentNullException(nameof(opCode)); - - _opCodes.Add(opCode); - } - - public void PushRange(IEnumerable opCodes) - { - if (opCodes is null) - throw new ArgumentNullException(nameof(opCodes)); - - foreach (IOpCode opCode in opCodes) - Push(opCode); - } - - public IEnumerator GetEnumerator() - { - return _opCodes.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public int Count => _opCodes.Count; - - public IOpCode this[int index] => _opCodes[index]; - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/PyProcessor.Events.cs b/src/Mellis.Lang.Python3/PyProcessor.Events.cs deleted file mode 100644 index 36679e2..0000000 --- a/src/Mellis.Lang.Python3/PyProcessor.Events.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using Mellis.Core.Entities; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Resources; - -namespace Mellis.Lang.Python3 -{ - public partial class PyProcessor - { - public event EventHandler ProcessEnded; - - public event EventHandler ScopeChanged; - - protected virtual void OnProcessEnded(ProcessState e) - { - ProcessEnded?.Invoke(this, e); - - // Only check on clean end, ignore if ended with error - if (e == ProcessState.Ended && GlobalScope != CurrentScope) - { - var ex = new InternalException( - nameof(Localized_Python3_Interpreter.Ex_Scope_LastScopeNotPopped), - Localized_Python3_Interpreter.Ex_Scope_LastScopeNotPopped); - - State = ProcessState.Error; - LastError = ex; - - throw ex; - } - } - - protected virtual void OnScopeChanged(IScopeContext e) - { - ScopeChanged?.Invoke(this, e); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/PyProcessor.Scope.cs b/src/Mellis.Lang.Python3/PyProcessor.Scope.cs deleted file mode 100644 index 53a8675..0000000 --- a/src/Mellis.Lang.Python3/PyProcessor.Scope.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Linq; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Resources; - -namespace Mellis.Lang.Python3 -{ - public partial class PyProcessor - { - public void PushScope() - { - var newScope = new PyScope(CurrentScope); - - _scopesStack.Add(newScope); - OnScopeChanged(newScope); - } - - public void PopScope() - { - if (_scopesStack.Count == 0) - { - throw new InternalException( - nameof(Localized_Python3_Interpreter.Ex_Scope_PopGlobal), - Localized_Python3_Interpreter.Ex_Scope_PopGlobal); - } - - _scopesStack.RemoveAt(_scopesStack.Count - 1); - OnScopeChanged(CurrentScope); - } - - public void SetGlobalVariable(string key, IScriptType value) - { - _globalScope.SetVariable(key, value); - } - - public void SetVariable(string key, IScriptType value) - { - var scope = (PyScope)CurrentScope; - - scope.SetVariable(key, value); - } - - public IScriptType GetVariable(string key) - { - PyScope scope = GetScopeWithVariableOrNull(key); - - if (scope == null) - throw new RuntimeException( - nameof(Localized_Python3_Runtime.Ex_Variable_NotDefined), - Localized_Python3_Runtime.Ex_Variable_NotDefined, - key); - - return scope.GetVariable(key); - } - - private PyScope GetScopeWithVariableOrNull(string key) - { - PyScope scope = _scopesStack.LastOrDefault() - ?? _globalScope; - - while (scope != null) - { - if (scope.HasVariable(key)) - return scope; - - scope = (PyScope)scope.ParentScope; - } - - return null; - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/PyProcessor.ValueStack.cs b/src/Mellis.Lang.Python3/PyProcessor.ValueStack.cs deleted file mode 100644 index 6cc4d91..0000000 --- a/src/Mellis.Lang.Python3/PyProcessor.ValueStack.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Resources; - -namespace Mellis.Lang.Python3 -{ - public partial class PyProcessor - { - internal int ValueStackCount => _valueStack.Count; - - internal IScriptType PopValue() - { - if (_valueStack.Count == 0) - { - throw new InternalException( - nameof(Localized_Python3_Interpreter.Ex_ValueStack_PopEmpty), - Localized_Python3_Interpreter.Ex_ValueStack_PopEmpty); - } - - return _valueStack.Pop(); - } - - internal void PushValue(IScriptType value) - { - if (value is null) - { - throw new InternalException( - nameof(Localized_Python3_Interpreter.Ex_ValueStack_PushNull), - Localized_Python3_Interpreter.Ex_ValueStack_PushNull); - } - - _valueStack.Push(value); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/PyProcessor.Walker.cs b/src/Mellis.Lang.Python3/PyProcessor.Walker.cs deleted file mode 100644 index 165ffb0..0000000 --- a/src/Mellis.Lang.Python3/PyProcessor.Walker.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.ComponentModel; -using Mellis.Core.Entities; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Instructions; -using Mellis.Lang.Python3.Interfaces; -using Mellis.Lang.Python3.Resources; - -namespace Mellis.Lang.Python3 -{ - public partial class PyProcessor - { - private int _numOfJumpsThisWalk = 0; - - // Oliver & Fredrik approved ✔️ - private const int JUMPS_THRESHOLD = 102+137; - - public void ContinueYieldedValue(IScriptType value) - { - throw new System.NotImplementedException(); - } - - public void WalkLine() - { - _numOfJumpsThisWalk = 0; - - WalkInstruction(); - - // Because counter starts at -1 - int? initialRow = GetRow(ProgramCounter); - - if (initialRow.HasValue) - { - // Initial is row => walk until next is other row - while (!(GetRow(ProgramCounter + 1) > initialRow.Value) && - State == ProcessState.Running && - _numOfJumpsThisWalk < JUMPS_THRESHOLD) - WalkInstruction(); - } - else - { - // Initial is clr => walk until next is line - while (GetRow(ProgramCounter + 1) == null && - State == ProcessState.Running && - _numOfJumpsThisWalk < JUMPS_THRESHOLD) - WalkInstruction(); - } - - int? GetRow(int i) - { - var source = GetSourceReference(i); - return source.IsFromClr - ? (int?) null - : source.FromRow; - } - } - - public void WalkInstruction() - { - switch (State) - { - case ProcessState.Ended: - case ProcessState.Error: - throw new InternalException( - nameof(Localized_Python3_Interpreter.Ex_Process_Ended), - Localized_Python3_Interpreter.Ex_Process_Ended); - - case ProcessState.Yielded: - throw new InternalException( - nameof(Localized_Python3_Interpreter.Ex_Process_Yielded), - Localized_Python3_Interpreter.Ex_Process_Yielded); - - case ProcessState.NotStarted when _opCodes.Length == 0: - State = ProcessState.Ended; - OnProcessEnded(State); - break; - - case ProcessState.NotStarted: - case ProcessState.Running: - try - { - ProgramCounter++; - _opCodes[ProgramCounter].Execute(this); - - if (ProgramCounter + 1 < _opCodes.Length) - State = ProcessState.Running; - else - { - State = ProcessState.Ended; - OnProcessEnded(State); - } - } - catch (InterpreterException ex) - { - State = ProcessState.Error; - LastError = ex; - - OnProcessEnded(State); - throw; - } - catch (Exception ex) - { - State = ProcessState.Error; - - LastError = new InterpreterLocalizedException( - nameof(Localized_Python3_Interpreter.Ex_Unknown_Error), - Localized_Python3_Interpreter.Ex_Unknown_Error, - ex, ex.Message); - - OnProcessEnded(State); - throw LastError; - } - - break; - - default: - throw new InvalidEnumArgumentException(nameof(State), (int)State, typeof(ProcessState)); - } - } - - private SourceReference GetSourceReference(int opCodeIndex) - { - if (opCodeIndex >= 0 && opCodeIndex < _opCodes.Length) - return _opCodes[opCodeIndex].Source; - - return SourceReference.ClrSource; - } - - internal void JumpToInstruction(int index) - { - ProgramCounter = index - 1; - _numOfJumpsThisWalk++; - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/PyProcessor.cs b/src/Mellis.Lang.Python3/PyProcessor.cs deleted file mode 100644 index b67f14e..0000000 --- a/src/Mellis.Lang.Python3/PyProcessor.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Mellis.Core.Entities; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Instructions; -using Mellis.Lang.Python3.Interfaces; - -namespace Mellis.Lang.Python3 -{ - public partial class PyProcessor : IProcessor - { - internal PyProcessor(params IOpCode[] opCodes) - { - Factory = new PyScriptTypeFactory(this); - State = ProcessState.NotStarted; - LastError = null; - - _valueStack = new Stack(); - _globalScope = new PyScope(null); - _scopesStack = new List(); - ProgramCounter = -1; - _opCodes = opCodes ?? new IOpCode[0]; - - // Assign indexes to labels - for (var i = 0; i < _opCodes.Length; i++) - { - if (_opCodes[i] is Label label) - label.OpCodeIndex = i; - } - } - - public IScriptTypeFactory Factory { get; } - - public IScopeContext GlobalScope => _globalScope; - - public IScopeContext CurrentScope => _scopesStack.LastOrDefault() - ?? GlobalScope; - - public ProcessState State { get; private set; } - - public SourceReference CurrentSource => GetSourceReference(ProgramCounter); - - public InterpreterException LastError { get; private set; } - - public int ProgramCounter { get; private set; } - - private readonly Stack _valueStack; - private readonly List _scopesStack; - private readonly PyScope _globalScope; - private readonly IOpCode[] _opCodes; - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/PyScope.cs b/src/Mellis.Lang.Python3/PyScope.cs deleted file mode 100644 index 9b5a31b..0000000 --- a/src/Mellis.Lang.Python3/PyScope.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using Mellis.Core.Interfaces; - -namespace Mellis.Lang.Python3 -{ - public class PyScope : IScopeContext - { - private readonly Dictionary _variables; - - public PyScope(IScopeContext parent) - { - _variables = new Dictionary(); - ParentScope = parent; - } - - public IScopeContext ParentScope { get; } - - public IReadOnlyDictionary Variables => _variables; - - internal void SetVariable(string key, IScriptType value) - { - _variables[key] = value; - } - - internal IScriptType GetVariable(string key) - { - return _variables.TryGetValue(key, out IScriptType value) - ? value - : null; - } - - internal bool HasVariable(string key) - { - return _variables.ContainsKey(key); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/PyScriptTypeFactory.cs b/src/Mellis.Lang.Python3/PyScriptTypeFactory.cs deleted file mode 100644 index 7f6fe5f..0000000 --- a/src/Mellis.Lang.Python3/PyScriptTypeFactory.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Collections.Generic; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Entities; - -namespace Mellis.Lang.Python3 -{ - public class PyScriptTypeFactory : IScriptTypeFactory - { - private readonly PyProcessor _processor; - - public PyScriptTypeFactory(PyProcessor processor) - { - _processor = processor; - True = new PyBoolean(_processor, true); - False = new PyBoolean(_processor, false); - } - - public IScriptType Null { get; } - public IScriptType True { get; } - public IScriptType False { get; } - - public IScriptType Create(int value) - { - return new PyInteger(_processor, value); - } - - public IScriptType Create(long value) - { - // TODO: introduce BigNumber - return new PyInteger(_processor, (int) value); - } - - public IScriptType Create(float value) - { - return new PyDouble(_processor, value); - } - - public IScriptType Create(double value) - { - return new PyDouble(_processor, value); - } - - public IScriptType Create(short value) - { - return new PyInteger(_processor, value); - } - - public IScriptType Create(byte value) - { - return new PyInteger(_processor, value); - } - - public IScriptType Create(char value) - { - return new PyString(_processor, value.ToString()); - } - - public IScriptType Create(string value) - { - return new PyString(_processor, value); - } - - public IScriptType Create(bool value) - { - return value ? True : False; - } - - public IScriptType Create(IList value) - { - throw new System.NotImplementedException(); - } - - public IScriptType Create(IDictionary value) - { - throw new System.NotImplementedException(); - } - - public IScriptType Create(IFunction value) - { - throw new System.NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Interpreter.Designer.cs b/src/Mellis.Lang.Python3/Resources/Localized_Python3_Interpreter.Designer.cs deleted file mode 100644 index f2f8d52..0000000 --- a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Interpreter.Designer.cs +++ /dev/null @@ -1,126 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Mellis.Lang.Python3.Resources { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Localized_Python3_Interpreter { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Localized_Python3_Interpreter() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mellis.Lang.Python3.Resources.Localized_Python3_Interpreter", typeof(Localized_Python3_Interpreter).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Koden har redan kört klart.. - /// - internal static string Ex_Process_Ended { - get { - return ResourceManager.GetString("Ex_Process_Ended", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Koden inväntar att funktionen återupptas innan den kan köra vidare.. - /// - internal static string Ex_Process_Yielded { - get { - return ResourceManager.GetString("Ex_Process_Yielded", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Internt fel. Alla variabelgrupper (scopes) blev inte korrekt stängda.. - /// - internal static string Ex_Scope_LastScopeNotPopped { - get { - return ResourceManager.GetString("Ex_Scope_LastScopeNotPopped", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Internt fel. En operation försökte stänga den globala variabelgruppen.. - /// - internal static string Ex_Scope_PopGlobal { - get { - return ResourceManager.GetString("Ex_Scope_PopGlobal", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Okänt internt fel. "{0}". - /// - internal static string Ex_Unknown_Error { - get { - return ResourceManager.GetString("Ex_Unknown_Error", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Internt fel. Värde stacken var oförväntat tom vid försök att hämta värde.. - /// - internal static string Ex_ValueStack_PopEmpty { - get { - return ResourceManager.GetString("Ex_ValueStack_PopEmpty", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Internt fel. En operation försökte trycka på null på värde stacken.. - /// - internal static string Ex_ValueStack_PushNull { - get { - return ResourceManager.GetString("Ex_ValueStack_PushNull", resourceCulture); - } - } - } -} diff --git a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Interpreter.resx b/src/Mellis.Lang.Python3/Resources/Localized_Python3_Interpreter.resx deleted file mode 100644 index 5aceafe..0000000 --- a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Interpreter.resx +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Koden har redan kört klart. - Processor asked to walk when already ended in state "Ended" or "Error". - - - Koden inväntar att funktionen återupptas innan den kan köra vidare. - Process asked to walk when reached state "Yielded". - - - Internt fel. Alla variabelgrupper (scopes) blev inte korrekt stängda. - Occurs on process ended but current scope was not brought back to global scope (via op-codes). - - - Internt fel. En operation försökte stänga den globala variabelgruppen. - Occurs when current scope is the global scope and PyProcessor.PopScope is invoked. - - - Okänt internt fel. "{0}" - Processor catched an exception that was not of type InterpreterException. -{0} message of inner exception - - - Internt fel. Värde stacken var oförväntat tom vid försök att hämta värde. - Occurs on attempting to pop on an empty value stack. - - - Internt fel. En operation försökte trycka på null på värde stacken. - Occurs on processor value stack is pushed with null. - - \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Parser.Designer.cs b/src/Mellis.Lang.Python3/Resources/Localized_Python3_Parser.Designer.cs deleted file mode 100644 index 6742347..0000000 --- a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Parser.Designer.cs +++ /dev/null @@ -1,135 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Mellis.Lang.Python3.Resources { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Localized_Python3_Parser { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Localized_Python3_Parser() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mellis.Lang.Python3.Resources.Localized_Python3_Parser", typeof(Localized_Python3_Parser).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Ogiltigt format på värdet i koden.. - /// - internal static string Ex_Literal_Format { - get { - return ResourceManager.GetString("Ex_Literal_Format", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Saknar en '{4}' som slutparantes.. - /// - internal static string Ex_Parenthesis_NoClosing { - get { - return ResourceManager.GetString("Ex_Parenthesis_NoClosing", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Förväntar en regel men det var tomt efter '{4}'.. - /// - internal static string Ex_Syntax_ExpectedChild { - get { - return ResourceManager.GetString("Ex_Syntax_ExpectedChild", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Saknar ett kolon i slutet av villkoret efter din 'elif'.. - /// - internal static string Ex_Syntax_If_Elif_MissingColon { - get { - return ResourceManager.GetString("Ex_Syntax_If_Elif_MissingColon", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Saknar ett kolon i slutet av din 'else' i din 'if'-sats.. - /// - internal static string Ex_Syntax_If_Else_MissingColon { - get { - return ResourceManager.GetString("Ex_Syntax_If_Else_MissingColon", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Saknar ett kolon efter villkoret i slutet av din 'if'-sats.. - /// - internal static string Ex_Syntax_If_MissingColon { - get { - return ResourceManager.GetString("Ex_Syntax_If_MissingColon", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Användning av '{4}' stödjs inte än.. - /// - internal static string Ex_Syntax_NotYetImplemented_Keyword { - get { - return ResourceManager.GetString("Ex_Syntax_NotYetImplemented_Keyword", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Oförväntad regel av typ '{5}' i en '{4}'.. - /// - internal static string Ex_Syntax_UnexpectedChildType { - get { - return ResourceManager.GetString("Ex_Syntax_UnexpectedChildType", resourceCulture); - } - } - } -} diff --git a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Parser.resx b/src/Mellis.Lang.Python3/Resources/Localized_Python3_Parser.resx deleted file mode 100644 index 7f4e979..0000000 --- a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Parser.resx +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Ogiltigt format på värdet i koden. - Upon parse error on items such as invalid string or invalid number format. -{0} source start line -{1} source start column -{2} source end line -{3} source end column - - - Saknar en '{4}' som slutparantes. - If missing end parenthesis. -{0} source start line -{1} source start column -{2} source end line -{3} source end column -{4} missing parenthesis char - - - Förväntar en regel men det var tomt efter '{4}'. - If child is null in the compiling algo. Which should never happen. -{0} source start line -{1} source start column -{2} source end line -{3} source end column -{4} context rule name - - - Saknar ett kolon i slutet av villkoret efter din 'elif'. - Missing colon after elif condition in if-statement. -{0} source start line -{1} source start column -{2} source end line -{3} source end column - - - Saknar ett kolon i slutet av din 'else' i din 'if'-sats. - Missing colon after else keyword in if-statement. -{0} source start line -{1} source start column -{2} source end line -{3} source end column - - - Saknar ett kolon efter villkoret i slutet av din 'if'-sats. - Missing colon after condition in if-statement. -{0} source start line -{1} source start column -{2} source end line -{3} source end column - - - Användning av '{4}' stödjs inte än. - Error for not yet implemented feature. Fallbacks to Localized_Exception.Ex_Syntax_NotYetImplemented from the Core project if keyword is not specified programmatically. -{0} source start line -{1} source start column -{2} source end line -{3} source end column -{4} keyword - - - Oförväntad regel av typ '{5}' i en '{4}'. - If child is of wrong type. Which should only happen due to sloppy programming. -{0} source start line -{1} source start column -{2} source end line -{3} source end column -{4} context rule name -{5} child rule name - - \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Runtime.Designer.cs b/src/Mellis.Lang.Python3/Resources/Localized_Python3_Runtime.Designer.cs deleted file mode 100644 index ca25583..0000000 --- a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Runtime.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Mellis.Lang.Python3.Resources { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Localized_Python3_Runtime { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Localized_Python3_Runtime() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mellis.Lang.Python3.Resources.Localized_Python3_Runtime", typeof(Localized_Python3_Runtime).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Finns ingen variabel med namn '{0}' definierad.. - /// - internal static string Ex_Variable_NotDefined { - get { - return ResourceManager.GetString("Ex_Variable_NotDefined", resourceCulture); - } - } - } -} diff --git a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Runtime.resx b/src/Mellis.Lang.Python3/Resources/Localized_Python3_Runtime.resx deleted file mode 100644 index 9b63a0d..0000000 --- a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Runtime.resx +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Finns ingen variabel med namn '{0}' definierad. - Variable not found in local or global scope. -{0} name of variable - - \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Syntax.Designer.cs b/src/Mellis.Lang.Python3/Resources/Localized_Python3_Syntax.Designer.cs deleted file mode 100644 index ded757d..0000000 --- a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Syntax.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Mellis.Lang.Python3.Resources { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Localized_Python3_Syntax { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Localized_Python3_Syntax() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mellis.Lang.Python3.Resources.Localized_Python3_Syntax", typeof(Localized_Python3_Syntax).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Internt fel vid syntaxläsningen. Förväntade nod av typ '{0}' men fick '{1}'.. - /// - internal static string Ex_InvalidType { - get { - return ResourceManager.GetString("Ex_InvalidType", resourceCulture); - } - } - } -} diff --git a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Syntax.resx b/src/Mellis.Lang.Python3/Resources/Localized_Python3_Syntax.resx deleted file mode 100644 index 3d977cf..0000000 --- a/src/Mellis.Lang.Python3/Resources/Localized_Python3_Syntax.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Internt fel vid syntaxläsningen. Förväntade nod av typ '{0}' men fick '{1}'. - Wrong SyntaxNode when validating syntax tree. -{0} type name of expected -{1} actual type name - - \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/ExpressionNode.cs b/src/Mellis.Lang.Python3/Syntax/ExpressionNode.cs deleted file mode 100644 index 66c1edb..0000000 --- a/src/Mellis.Lang.Python3/Syntax/ExpressionNode.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Mellis.Core.Entities; - -namespace Mellis.Lang.Python3.Syntax -{ - public abstract class ExpressionNode : SyntaxNode - { - protected ExpressionNode(SourceReference source) - : base(source) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Identifier.cs b/src/Mellis.Lang.Python3/Syntax/Identifier.cs deleted file mode 100644 index 378d006..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Identifier.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax -{ - public class Identifier : ExpressionNode - { - public string Name { get; } - - public Identifier(SourceReference source, string name) : base(source) - { - Name = name; - } - - public override void Compile(PyCompiler compiler) - { - compiler.Push(new VarGet(Source, Name)); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Literal.cs b/src/Mellis.Lang.Python3/Syntax/Literal.cs deleted file mode 100644 index 1279388..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Literal.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Core.Interfaces; - -namespace Mellis.Lang.Python3.Syntax -{ - public abstract class Literal : ExpressionNode - { - protected Literal(SourceReference source, T value) - : base(source) - { - Value = value; - } - - public T Value { get; set; } - - public abstract IScriptType ToScriptType(PyProcessor processor); - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Literals/LiteralBoolean.cs b/src/Mellis.Lang.Python3/Syntax/Literals/LiteralBoolean.cs deleted file mode 100644 index c0c9fef..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Literals/LiteralBoolean.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Entities; -using Mellis.Lang.Python3.Exceptions; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Literals -{ - public class LiteralBoolean : Literal - { - public LiteralBoolean(SourceReference source, bool value) - : base(source, value) - { - } - - public static LiteralBoolean Parse(SourceReference source, string text) - { - switch (text) - { - case "True": - return new LiteralBoolean(source, true); - case "False": - return new LiteralBoolean(source, false); - - default: - throw new SyntaxLiteralFormatException(source); - } - } - - public override IScriptType ToScriptType(PyProcessor processor) - { - return new PyBoolean(processor, Value); - } - - public override void Compile(PyCompiler compiler) - { - compiler.Push(new PushLiteral(this)); - } - - public override string ToString() - { - return Value ? "True" : "False"; - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Literals/LiteralDouble.cs b/src/Mellis.Lang.Python3/Syntax/Literals/LiteralDouble.cs deleted file mode 100644 index 0df6185..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Literals/LiteralDouble.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Globalization; -using Mellis.Core.Entities; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Entities; -using Mellis.Lang.Python3.Exceptions; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Literals -{ - public class LiteralDouble : Literal - { - public LiteralDouble(SourceReference source, double value) - : base(source, value) - { - } - - public static LiteralDouble Parse(SourceReference source, string text) - { - // floatnumber ::= pointfloat | exponentfloat - - if (double.TryParse(text, - NumberStyles.AllowExponent | - NumberStyles.AllowDecimalPoint, - CultureInfo.InvariantCulture, out double value)) - { - return new LiteralDouble(source, value); - } - - throw new SyntaxLiteralFormatException(source); - } - - public override IScriptType ToScriptType(PyProcessor processor) - { - return new PyDouble(processor, Value); - } - - public override void Compile(PyCompiler compiler) - { - compiler.Push(new PushLiteral(this)); - } - - public override string ToString() - { - return Value.ToString(CultureInfo.InvariantCulture); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Literals/LiteralInteger.cs b/src/Mellis.Lang.Python3/Syntax/Literals/LiteralInteger.cs deleted file mode 100644 index 481a1bf..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Literals/LiteralInteger.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Globalization; -using Mellis.Core.Entities; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Entities; -using Mellis.Lang.Python3.Exceptions; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Literals -{ - public class LiteralInteger : Literal - { - public LiteralInteger(SourceReference source, int value) - : base(source, value) - { - } - - public static LiteralInteger Parse(SourceReference source, string text) - { - if (text.Length > 2 && text[0] == '0') - { - switch (text[1]) - { - case 'B': - case 'b': - // bininteger ::= "0" ("b" | "B") bindigit+ - throw new SyntaxNotYetImplementedException(source); - case 'O': - case 'o': - // octinteger ::= "0" ("o" | "O") octdigit+ - throw new SyntaxNotYetImplementedException(source); - - case 'X': - case 'x': - // hexinteger ::= "0" ("x" | "X") hexdigit+ - if (int.TryParse(text.Substring(2), - NumberStyles.AllowHexSpecifier, - CultureInfo.InvariantCulture, - out int hexValue)) - { - return new LiteralInteger(source, hexValue); - } - - throw new SyntaxLiteralFormatException(source); - } - } - - // decimalinteger ::= nonzerodigit digit* | "0"+ - if (int.TryParse(text, out int integer)) - { - return new LiteralInteger(source, integer); - } - - throw new SyntaxLiteralFormatException(source); - } - - public override IScriptType ToScriptType(PyProcessor processor) - { - return new PyInteger(processor, Value); - } - - public override void Compile(PyCompiler compiler) - { - compiler.Push(new PushLiteral(this)); - } - - public override string ToString() - { - return Value.ToString(CultureInfo.InvariantCulture); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Literals/LiteralString.cs b/src/Mellis.Lang.Python3/Syntax/Literals/LiteralString.cs deleted file mode 100644 index 5a7a223..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Literals/LiteralString.cs +++ /dev/null @@ -1,392 +0,0 @@ -using System; -using System.Globalization; -using System.Text; -using Mellis.Core.Entities; -using Mellis.Core.Exceptions; -using Mellis.Core.Interfaces; -using Mellis.Lang.Python3.Entities; -using Mellis.Lang.Python3.Exceptions; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Literals -{ - public class LiteralString : Literal - { - public LiteralString(SourceReference source, string value) - : base(source, value) - { - } - - public override IScriptType ToScriptType(PyProcessor processor) - { - return new PyString(processor, Value); - } - - public override void Compile(PyCompiler compiler) - { - compiler.Push(new PushLiteral(this)); - } - - public override string ToString() - { - return Escape(Value); - } - - public static LiteralString Parse(SourceReference source, string text) - { - // At least 2 for an empty quoted string - if (text.Length < 2) - { - throw new SyntaxLiteralFormatException(source); - } - - string modifiers = GetModifiers(); - string withoutModifiers = text.Substring(modifiers.Length); - string quotes = GetQuotes(); - - // Check it's longer than quotes - if (withoutModifiers.Length < quotes.Length * 2) - { - throw new SyntaxLiteralFormatException(source); - } - - // Check ending with correct quotes - if (withoutModifiers.Substring(withoutModifiers.Length - quotes.Length) != quotes) - { - throw new SyntaxLiteralFormatException(source); - } - - string withoutQuotes = withoutModifiers.Substring(quotes.Length, - withoutModifiers.Length - quotes.Length * 2); - switch (modifiers.ToLowerInvariant()) - { - case "": - return new LiteralString(source, Unescape(withoutQuotes)); - - case "r": // raw - return new LiteralString(source, withoutQuotes); - - case "b": // bytes - case "br": // raw+bytes - case "rb": // raw+bytes - case "f": // formatted - case "rf": // raw+formatted - case "fr": // raw+formatted - case "u": // unicode - throw new SyntaxNotYetImplementedException(source); - - default: - throw new SyntaxLiteralFormatException(source); - } - - string GetQuotes() - { - if (withoutModifiers.Length == 0) - throw new SyntaxLiteralFormatException(source); - - char quote = withoutModifiers[0]; - var longStringQuotes = new string(quote, 3); - return withoutModifiers.StartsWith(longStringQuotes) - ? longStringQuotes - : quote.ToString(); - } - - string GetModifiers() - { - var builder = new StringBuilder(); - - foreach (char c in text) - { - if (c == '"' || c == '\'') - return builder.ToString(); - - builder.Append(c); - } - - return builder.ToString(); - } - } - - /// - /// Replaces escaped characters with the actual character. - /// NOTE: This is not the reverse of . This does not remove the surrounding quotes created by . - /// - public static string Unescape(string value) - { - var builder = new StringBuilder(value.Length); - - for (var i = 0; i < value.Length; i++) - { - char c = value[i]; - if (c == '\\') - { - if (i + 1 >= value.Length) - { - builder.Append(value[i]); - continue; - } - - if (GetEscapedChar(i + 1, out c)) - { - builder.Append(c); - i++; - } - else if (GetOctalChars(i, out string oStr)) - { - builder.Append((char) Convert.ToInt32(oStr, 8)); - i += oStr.Length; - } - else if (GetHexChars(i, out string xStr)) - { - builder.Append((char) Convert.ToInt32(xStr, 16)); - i += xStr.Length + 1; - } - else - { - builder.Append(value[i]); - builder.Append(value[++i]); - } - } - else - { - builder.Append(c); - } - } - - return builder.ToString(); - - bool GetEscapedChar(int i, out char c) - { - switch (value[i]) - { - case '\\': - c = '\\'; - break; - case '\'': - c = '\''; - break; - case '"': - c = '"'; - break; - case 'a': - c = '\a'; - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'v': - c = '\v'; - break; - default: - c = default; - return false; - } - - return true; - } - - bool GetOctalChars(int i, out string octString) - { - var b = new StringBuilder(3); - - // Skip the / - i++; - - for (; i < value.Length && b.Length < 3; i++) - { - char v = value[i]; - if (v >= '0' && v <= '7') - b.Append(v); - else - break; - } - - if (b.Length > 0) - { - octString = b.ToString(); - return true; - } - - octString = default; - return false; - } - - bool GetHexChars(int i, out string hexStr) - { - var b = new StringBuilder(3); - - // Skip the / - i++; - - if (value.Length > i && value[i] == 'x') - { - // Skip the x - i++; - - for (; i < value.Length && b.Length < 2; i++) - { - char v = value[i]; - if (v >= '0' && v <= '9' || - v >= 'a' && v <= 'f' || - v >= 'A' && v <= 'F') - b.Append(v); - else - break; - } - - if (b.Length > 0) - { - hexStr = b.ToString(); - return true; - } - } - - hexStr = default; - return false; - } - } - - public static string Escape(string value) - { - // Algorithm ported from - // https://github.com/python/cpython/blob/3.7/Objects/unicodeobject.c#L12609 - - // Compute quote characters - bool singleQuotes = value.IndexOf('\'') != -1; - - // Prefer single quotes - char quote = !singleQuotes ? '\'' : '"'; - var builder = new StringBuilder(value.Length + 10); - - builder.Append(quote); - - for (var i = 0; i < value.Length; i++) - { - char c = value[i]; - - switch (c) - { - // Escape quotes and backslashes - case '\'' when quote == '\'': - case '"' when quote == '"': - case '\\': - builder.Append('\\'); - builder.Append(c); - break; - - // Map special whitespace to '\t', \n', '\r' - case '\a': - builder.Append("\\a"); - break; - case '\b': - builder.Append("\\b"); - break; - case '\f': - builder.Append("\\f"); - break; - case '\n': - builder.Append("\\n"); - break; - case '\r': - builder.Append("\\r"); - break; - case '\t': - builder.Append("\\t"); - break; - case '\v': - builder.Append("\\v"); - break; - - default: - // Map non-printable US ASCII to '\xhh' - if (c < ' ' || c == '\x7F') - { - builder.AppendFormat("\\x{0:x2}", (int) c); - } - // Copy ASCII characters as-is - else if (c < '\x7F') - { - builder.Append(c); - } - // Non-ASCII characters - else - { - if (!IsPrintable(value, i)) - { - // Map 8-bit characters to '\xhh' - if (c <= '\xff') - { - builder.AppendFormat("\\x{0:x2}", (int) c); - } - else - { - int c32 = char.ConvertToUtf32(c, value[++i]); - // Map 16 - bit characters to '\uxxxx' - if (c32 <= 0xffff) - { - builder.AppendFormat("\\u{0:x4}", c32); - } - // Map 21-bit characters to '\U00xxxxxx' - else - { - builder.AppendFormat("\\U{0:x8}", c32); - } - } - } - else if (char.IsSurrogatePair(value, i)) - { - // special because c# only handles 16bit in char - builder.Append(value.Substring(i, 2)); - i++; - } - else - { - // Copy characters as-is - builder.Append(c); - } - } - - break; - } // switch - } // for - - // Closing quote already added at the beginning - builder.Append(quote); - - return builder.ToString(); - } - - private static bool IsPrintable(string value, int index) - { - // According to cpython/Objects/unicodectype.c - // https://github.com/python/cpython/blob/3.7/Objects/unicodectype.c#L147 - switch (char.GetUnicodeCategory(value, index)) - { - case UnicodeCategory.Control: - case UnicodeCategory.Format: - case UnicodeCategory.Surrogate: - case UnicodeCategory.PrivateUse: - case UnicodeCategory.OtherNotAssigned: - case UnicodeCategory.LineSeparator: - case UnicodeCategory.ParagraphSeparator: - case UnicodeCategory.SpaceSeparator: - return false; - - default: - return true; - } - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticAdd.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticAdd.cs deleted file mode 100644 index 97bfe69..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticAdd.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Arithmetics -{ - public class ArithmeticAdd : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.AAdd; - - public ArithmeticAdd( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticDivide.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticDivide.cs deleted file mode 100644 index 8e0f955..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticDivide.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Arithmetics -{ - public class ArithmeticDivide : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.ADiv; - - public ArithmeticDivide( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticFloor.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticFloor.cs deleted file mode 100644 index ada0d7b..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticFloor.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Arithmetics -{ - public class ArithmeticFloor : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.AFlr; - - public ArithmeticFloor( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticModulus.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticModulus.cs deleted file mode 100644 index 63d65ea..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticModulus.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Arithmetics -{ - public class ArithmeticModulus : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.AMod; - - public ArithmeticModulus( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticMultiply.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticMultiply.cs deleted file mode 100644 index 26e1e8c..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticMultiply.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Arithmetics -{ - public class ArithmeticMultiply : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.AMul; - - public ArithmeticMultiply( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticNegative.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticNegative.cs deleted file mode 100644 index 2d6bc68..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticNegative.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Arithmetics -{ - public class ArithmeticNegative : UnaryOperator - { - public override OperatorCode OpCode => OperatorCode.ANeg; - - public ArithmeticNegative(SourceReference source, - ExpressionNode operand) - : base(source, operand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticPositive.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticPositive.cs deleted file mode 100644 index b18646e..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticPositive.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Arithmetics -{ - public class ArithmeticPositive : UnaryOperator - { - public override OperatorCode OpCode => OperatorCode.APos; - - public ArithmeticPositive(SourceReference source, - ExpressionNode operand) - : base(source, operand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticPower.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticPower.cs deleted file mode 100644 index b42a49f..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticPower.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Arithmetics -{ - public class ArithmeticPower : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.APow; - - public ArithmeticPower( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticSubtract.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticSubtract.cs deleted file mode 100644 index dc86a8f..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Arithmetics/ArithmeticSubtract.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Arithmetics -{ - public class ArithmeticSubtract : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.ASub; - - public ArithmeticSubtract( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryAnd.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryAnd.cs deleted file mode 100644 index 088e89e..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryAnd.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Binaries -{ - public class BinaryAnd : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.BAnd; - - public BinaryAnd( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryLeftShift.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryLeftShift.cs deleted file mode 100644 index 4a567af..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryLeftShift.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Binaries -{ - public class BinaryLeftShift : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.BLsh; - - public BinaryLeftShift( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryNot.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryNot.cs deleted file mode 100644 index 56ebb57..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryNot.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Binaries -{ - public class BinaryNot : UnaryOperator - { - public override OperatorCode OpCode => OperatorCode.BNot; - - public BinaryNot(SourceReference source, - ExpressionNode operand) - : base(source, operand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryOr.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryOr.cs deleted file mode 100644 index 7a5c388..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryOr.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Binaries -{ - public class BinaryOr : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.BOr; - - public BinaryOr( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryRightShift.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryRightShift.cs deleted file mode 100644 index 403d305..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryRightShift.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Binaries -{ - public class BinaryRightShift : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.BRsh; - - public BinaryRightShift( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryXor.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryXor.cs deleted file mode 100644 index 02702be..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Binaries/BinaryXor.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Binaries -{ - public class BinaryXor : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.BXor; - - public BinaryXor( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/BinaryOperator.cs b/src/Mellis.Lang.Python3/Syntax/Operators/BinaryOperator.cs deleted file mode 100644 index 871a303..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/BinaryOperator.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators -{ - /// - /// Common two part operators, such as "and" (a && b), "or" (a || b), "xor" (a ^ b) - /// - public abstract class BinaryOperator : ExpressionNode - { - public abstract OperatorCode OpCode { get; } - - protected BinaryOperator(SourceReference source, - ExpressionNode leftOperand, ExpressionNode rightOperand) - : base(source) - { - LeftOperand = leftOperand; - RightOperand = rightOperand; - } - - // You can happily merge them without conflict - // since the operator source will always be the - // combined range from lhs to rhs - protected BinaryOperator( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : this(SourceReference.Merge(leftOperand.Source, rightOperand.Source), - leftOperand, rightOperand) - { - } - - public ExpressionNode LeftOperand { get; } - public ExpressionNode RightOperand { get; } - - public override void Compile(PyCompiler compiler) - { - LeftOperand.Compile(compiler); - RightOperand.Compile(compiler); - compiler.Push(new BasicOperator(Source, OpCode)); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Comparison.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Comparison.cs deleted file mode 100644 index d37d33f..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Comparison.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Mellis.Lang.Python3.Syntax.Operators -{ - public abstract class Comparison : BinaryOperator - { - public abstract ComparisonType Type { get; } - - protected Comparison(ExpressionNode leftOperand, ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/ComparisonFactory.cs b/src/Mellis.Lang.Python3/Syntax/Operators/ComparisonFactory.cs deleted file mode 100644 index 4c263df..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/ComparisonFactory.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System.ComponentModel; -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Exceptions; -using Mellis.Lang.Python3.Resources; -using Mellis.Lang.Python3.Syntax.Operators.Comparisons; - -namespace Mellis.Lang.Python3.Syntax.Operators -{ - public class ComparisonFactory : SyntaxNode - { - public ComparisonType Type { get; } - public string Keyword => GetKeyword(Type); - - public ComparisonFactory(ComparisonType type) - : base(SourceReference.ClrSource) - { - Type = type; - } - - public Comparison Create(ExpressionNode leftOperand, ExpressionNode rightOperand) - { - switch (Type) - { - case ComparisonType.Equals: - return new CompareEquals(leftOperand, rightOperand); - - case ComparisonType.LessThan: - case ComparisonType.LessThanOrEqual: - case ComparisonType.GreaterThan: - case ComparisonType.GreaterThanOrEqual: - case ComparisonType.NotEquals: - case ComparisonType.NotEqualsABC: - case ComparisonType.In: - case ComparisonType.InNot: - case ComparisonType.Is: - case ComparisonType.IsNot: - throw new SyntaxNotYetImplementedExceptionKeyword( - source: Source, - keyword: Keyword); - default: - throw new InvalidEnumArgumentException(nameof(Type), (int) Type, typeof(ComparisonType)); - } - } - - /// - /// Used in errors, such as the keyworded NotYetImplemented - /// - public static string GetKeyword(ComparisonType type) - { - switch (type) - { - case ComparisonType.LessThan: - return "<"; - case ComparisonType.LessThanOrEqual: - return "<="; - case ComparisonType.GreaterThan: - return ">"; - case ComparisonType.GreaterThanOrEqual: - return ">="; - case ComparisonType.Equals: - return "=="; - case ComparisonType.NotEquals: - return "!="; - case ComparisonType.NotEqualsABC: - return "<>"; - case ComparisonType.In: - return "in"; - case ComparisonType.InNot: - return "not in"; - case ComparisonType.Is: - return "is"; - case ComparisonType.IsNot: - return "is not"; - default: - throw new InvalidEnumArgumentException(nameof(type), (int) type, typeof(ComparisonType)); - } - } - - public override void Compile(PyCompiler compiler) - { - throw new System.NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/ComparisonType.cs b/src/Mellis.Lang.Python3/Syntax/Operators/ComparisonType.cs deleted file mode 100644 index 0b00954..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/ComparisonType.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace Mellis.Lang.Python3.Syntax.Operators -{ - public enum ComparisonType - { - /// a < b - LessThan, - - /// a <= b - LessThanOrEqual, - - /// a > b - GreaterThan, - - /// a >= b - GreaterThanOrEqual, - - /// a == b - Equals, - - /// a != b - NotEquals, - - /// - /// a <> b - /// - /// Unsupported syntax, but included in the grammar. Comes from the ABC language - /// - /// - NotEqualsABC, - - /// a in b - In, - - /// a not in b - InNot, - - /// a is b - Is, - - /// a is not b - IsNot, - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Comparisons/CompareEquals.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Comparisons/CompareEquals.cs deleted file mode 100644 index da0704b..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Comparisons/CompareEquals.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Comparisons -{ - public class CompareEquals : Comparison - { - public override ComparisonType Type => ComparisonType.Equals; - - public override OperatorCode OpCode => OperatorCode.CEq; - - public CompareEquals(ExpressionNode leftOperand, ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Logicals/LogicalAnd.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Logicals/LogicalAnd.cs deleted file mode 100644 index e23465b..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Logicals/LogicalAnd.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Logicals -{ - public class LogicalAnd : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.LAnd; - - public LogicalAnd( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Logicals/LogicalNot.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Logicals/LogicalNot.cs deleted file mode 100644 index 3448226..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Logicals/LogicalNot.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Logicals -{ - public class LogicalNot : UnaryOperator - { - public override OperatorCode OpCode => OperatorCode.LNot; - - public LogicalNot(SourceReference source, - ExpressionNode operand) - : base(source, operand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/Logicals/LogicalOr.cs b/src/Mellis.Lang.Python3/Syntax/Operators/Logicals/LogicalOr.cs deleted file mode 100644 index 2100e17..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/Logicals/LogicalOr.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators.Logicals -{ - public class LogicalOr : BinaryOperator - { - public override OperatorCode OpCode => OperatorCode.LOr; - - public LogicalOr( - ExpressionNode leftOperand, - ExpressionNode rightOperand) - : base(leftOperand, rightOperand) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Operators/UnaryOperator.cs b/src/Mellis.Lang.Python3/Syntax/Operators/UnaryOperator.cs deleted file mode 100644 index a8cc9c5..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Operators/UnaryOperator.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Operators -{ - /// - /// Common for negating operators such as the "not" (!value), "binary not" (~value) - /// - public abstract class UnaryOperator : ExpressionNode - { - protected UnaryOperator(SourceReference source, ExpressionNode operand) - : base(SourceReference.Merge(source, operand.Source)) - { - Operand = operand; - } - - public ExpressionNode Operand { get; set; } - - public abstract OperatorCode OpCode { get; } - - public override void Compile(PyCompiler compiler) - { - Operand.Compile(compiler); - compiler.Push(new BasicOperator(Source, OpCode)); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Statement.cs b/src/Mellis.Lang.Python3/Syntax/Statement.cs deleted file mode 100644 index 7898a22..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Statement.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Mellis.Core.Entities; - -namespace Mellis.Lang.Python3.Syntax -{ - public abstract class Statement : SyntaxNode - { - protected Statement(SourceReference source) - : base(source) - { - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/StatementList.cs b/src/Mellis.Lang.Python3/Syntax/StatementList.cs deleted file mode 100644 index 05bbb18..0000000 --- a/src/Mellis.Lang.Python3/Syntax/StatementList.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Syntax.Statements; - -namespace Mellis.Lang.Python3.Syntax -{ - public class StatementList : Statement - { - public IReadOnlyList Statements { get; set; } - - public StatementList(SourceReference source, IReadOnlyList statements) - : base(source) - { - Statements = statements; - } - - public override void Compile(PyCompiler compiler) - { - foreach (Statement statement in Statements) - { - statement.Compile(compiler); - } - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Statements/Assignment.cs b/src/Mellis.Lang.Python3/Syntax/Statements/Assignment.cs deleted file mode 100644 index 640902f..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Statements/Assignment.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Core.Exceptions; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Statements -{ - public class Assignment : Statement - { - public ExpressionNode LeftOperand { get; } - public ExpressionNode RightOperand { get; } - - public Assignment(SourceReference source, - ExpressionNode leftOperand, ExpressionNode rightOperand) - : base(source) - { - LeftOperand = leftOperand; - RightOperand = rightOperand; - } - - public override void Compile(PyCompiler compiler) - { - switch (LeftOperand) - { - case Identifier id: - RightOperand.Compile(compiler); - compiler.Push(new VarSet(Source, id.Name)); - break; - - default: - throw new SyntaxNotYetImplementedException(LeftOperand.Source); - } - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/Statements/IfStatement.cs b/src/Mellis.Lang.Python3/Syntax/Statements/IfStatement.cs deleted file mode 100644 index 2768b85..0000000 --- a/src/Mellis.Lang.Python3/Syntax/Statements/IfStatement.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Mellis.Core.Entities; -using Mellis.Lang.Python3.Instructions; - -namespace Mellis.Lang.Python3.Syntax.Statements -{ - public class IfStatement : Statement - { - public IfStatement(SourceReference source, - ExpressionNode condition, - Statement ifSuite, - Statement elseSuite) : base(source) - { - Condition = condition; - IfSuite = ifSuite; - ElseSuite = elseSuite; - } - - public IfStatement(SourceReference source, - ExpressionNode condition, - Statement ifSuite) - : this(source, condition, ifSuite, null) - { - } - - public ExpressionNode Condition { get; } - - public Statement IfSuite { get; } - - public Statement ElseSuite { get; } - - public override void Compile(PyCompiler compiler) - { - var endLabel = new Label(Source.LastRow()); - - CompileWithEndLabel(compiler, endLabel); - - compiler.Push(endLabel); - } - - private void CompileWithEndLabel(PyCompiler compiler, Label endLabel) - { - Condition.Compile(compiler); - - switch (ElseSuite) - { - case IfStatement innerIf: - { - // Else is if statement - // Jump to inner-if if false - var elifLabel = new Label(innerIf.Source); - var jumpToElifIfFalse = new JumpIfFalse(Condition.Source, elifLabel); - compiler.Push(jumpToElifIfFalse); - - IfSuite.Compile(compiler); - - var jumpToEnd = new Jump(IfSuite.Source.LastRow(), endLabel); - compiler.Push(jumpToEnd); - compiler.Push(elifLabel); - - innerIf.CompileWithEndLabel(compiler, endLabel); - - if (innerIf.ElseSuite != null) - { - } - break; - } - - case null: - { - // No else, jump to end if false - var jumpToEndIfFalse = new JumpIfFalse(Condition.Source, endLabel); - compiler.Push(jumpToEndIfFalse); - IfSuite.Compile(compiler); - break; - } - - default: - { - // Else is any other statement - // Jump to else if false - var elseLabel = new Label(ElseSuite.Source); - var jumpToElseIfFalse = new JumpIfFalse(Condition.Source, elseLabel); - compiler.Push(jumpToElseIfFalse); - - IfSuite.Compile(compiler); - - var jumpToEnd = new Jump(IfSuite.Source.LastRow(), endLabel); - compiler.Push(jumpToEnd); - compiler.Push(elseLabel); - - ElseSuite.Compile(compiler); - break; - } - } - } - } -} \ No newline at end of file diff --git a/src/Mellis.Lang.Python3/Syntax/SyntaxNode.cs b/src/Mellis.Lang.Python3/Syntax/SyntaxNode.cs deleted file mode 100644 index 5eeb8ea..0000000 --- a/src/Mellis.Lang.Python3/Syntax/SyntaxNode.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mellis.Core.Entities; - -namespace Mellis.Lang.Python3.Syntax -{ - public abstract class SyntaxNode - { - protected SyntaxNode(SourceReference source) - { - Source = source; - } - - public SourceReference Source { get; } - - public abstract void Compile(PyCompiler compiler); - } -} \ No newline at end of file diff --git a/src/Mellis.Tools.Tests/AutoObject/AutoValueTests.cs b/src/Mellis.Tools.Tests/AutoObject/AutoValueTests.cs deleted file mode 100644 index 7b7c3ae..0000000 --- a/src/Mellis.Tools.Tests/AutoObject/AutoValueTests.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Mellis.Core.Interfaces; - -namespace Mellis.Tools.Tests.AutoObject -{ - [TestClass] - public class AutoValueTests - { - private Mock factoryMock; - private Mock processorMock; - private Mock valueMock; - - [TestInitialize] - public void TestInitialize() - { - factoryMock = new Mock(MockBehavior.Strict); - - processorMock = new Mock(MockBehavior.Strict); - processorMock.Setup(m => m.Factory).Returns(factoryMock.Object); - - valueMock = new Mock(MockBehavior.Strict); - valueMock.Setup(o => o.Processor) - .Returns(processorMock.Object); - } - - private void VerifyMocks() - { - factoryMock.Verify(); - processorMock.Verify(); - valueMock.Verify(); - } - - [TestMethod] - public void GetPublicPropertyTest() - { - // Arrange - const string testString = "foo"; - var model = new TestingClass - { - Processor = processorMock.Object, - PublicProperty = testString - }; - - factoryMock.Setup(o => o.Create(testString)) - .Returns(valueMock.Object); - - // Act - IScriptType value = model.GetProperty(nameof(model.PublicProperty)); - - // Assert - Assert.AreSame(value, valueMock.Object); - VerifyMocks(); - } - - [TestMethod] - public void GetPrivatePropertyTest() - { - // Arrange - const string testString = "foo"; - var model = new TestingClass - { - Processor = processorMock.Object, - }.WithPrivateProperty(testString); - - factoryMock.Setup(o => o.Create(testString)) - .Returns(valueMock.Object); - - // Act - IScriptType value = model.GetProperty(TestingClass.PrivatePropertyName); - - // Assert - Assert.AreSame(value, valueMock.Object); - VerifyMocks(); - } - - [TestMethod] - public void GetProtectedPropertyTest() - { - // Arrange - const string testString = "foo"; - var model = new TestingClass - { - Processor = processorMock.Object, - }.WithProtectedProperty(testString); - - factoryMock.Setup(o => o.Create(testString)) - .Returns(valueMock.Object); - - // Act - IScriptType value = model.GetProperty(TestingClass.ProtectedPropertyName); - - // Assert - Assert.AreSame(value, valueMock.Object); - VerifyMocks(); - } - - [TestMethod] - public void GetProtectedDerivedPropertyTest() - { - const string testString = "foo"; - - // Arrange - var model = new TestingDerivedClass - { - Processor = processorMock.Object, - }.WithProtectedProperty(testString); - - factoryMock.Setup(o => o.Create(testString)) - .Returns(valueMock.Object); - - // Act - IScriptType value = model.GetProperty(TestingClass.ProtectedPropertyName); - - // Assert - Assert.AreSame(value, valueMock.Object); - VerifyMocks(); - } - - [TestMethod] - public void GetNullTest() - { - // Arrange - const string testString = null; - var model = new TestingClass - { - Processor = processorMock.Object, - PublicProperty = testString - }; - - factoryMock.Setup(o => o.Null) - .Returns(valueMock.Object); - - // Act - IScriptType value = model.GetProperty(nameof(model.PublicProperty)); - - // Assert - Assert.AreSame(value, valueMock.Object); - VerifyMocks(); - } - - [TestMethod] - public void GetPropertyWithoutAttributeTest() - { - // Arrange - const string testString = null; - var model = new TestingClass - { - Processor = processorMock.Object, - PublicFieldWithoutAttribute = testString - }; - - factoryMock.Setup(o => o.Null) - .Returns(valueMock.Object); - - // Act - IScriptType value = model.GetProperty(nameof(model.PublicFieldWithoutAttribute)); - - // Assert - Assert.AreSame(value, valueMock.Object); - VerifyMocks(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Tools.Tests/AutoObject/TestingClass.cs b/src/Mellis.Tools.Tests/AutoObject/TestingClass.cs deleted file mode 100644 index eb390fb..0000000 --- a/src/Mellis.Tools.Tests/AutoObject/TestingClass.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Mellis.Core.Interfaces; -using Mellis.Tools.AutoObject; - -namespace Mellis.Tools.Tests.AutoObject -{ - public class TestingClass : AutoValueBase - { - public const string ProtectedPropertyName = nameof(ProtectedProperty); - public const string PrivatePropertyName = nameof(PrivateProperty); - public const string PrivateFieldName = nameof(PrivateField); - - [ShowInScript] - public string PublicProperty { get; set; } - - [ShowInScript] - protected string ProtectedProperty { get; set; } - - [ShowInScript] - private string PrivateProperty { get; set; } - - public string PublicPropertyWithoutAttribute { get; set; } - - [ShowInScript] - private string PrivateField; - - [ShowInScript] - public string PublicField; - - public string PublicFieldWithoutAttribute; - - public TestingClass WithProtectedProperty(string value) - { - ProtectedProperty = value; - return this; - } - - public TestingClass WithPrivateProperty(string value) - { - PrivateProperty = value; - return this; - } - - public TestingClass WithPrivatePropertyField(string value) - { - PrivateField = value; - return this; - } - - public override IScriptType GetTypeDef() - { - throw new System.NotImplementedException(); - } - - public override string GetTypeName() - { - throw new System.NotImplementedException(); - } - - public override IScriptType Invoke(IScriptType[] arguments) - { - throw new System.NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Tools.Tests/AutoObject/TestingDerivedClass.cs b/src/Mellis.Tools.Tests/AutoObject/TestingDerivedClass.cs deleted file mode 100644 index a0d4117..0000000 --- a/src/Mellis.Tools.Tests/AutoObject/TestingDerivedClass.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Mellis.Tools.Tests.AutoObject -{ - public class TestingDerivedClass : TestingClass - { - } -} \ No newline at end of file diff --git a/src/Mellis.Tools.Tests/Mellis.Tools.Tests.csproj b/src/Mellis.Tools.Tests/Mellis.Tools.Tests.csproj deleted file mode 100644 index a4aeb78..0000000 --- a/src/Mellis.Tools.Tests/Mellis.Tools.Tests.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - netcoreapp2.1 - - false - - latest - - - - - - - - - - - - - - - - diff --git a/src/Mellis.Tools.Tests/ScriptTypeFactoryExtensionsTests.cs b/src/Mellis.Tools.Tests/ScriptTypeFactoryExtensionsTests.cs deleted file mode 100644 index cbf33c7..0000000 --- a/src/Mellis.Tools.Tests/ScriptTypeFactoryExtensionsTests.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Castle.DynamicProxy.Internal; -using Microsoft.VisualStudio.TestPlatform.ObjectModel; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Moq; -using Mellis.Core.Interfaces; -using Mellis.Lang.Base.Entities; -using Mellis.Tools.Extensions; - -namespace Mellis.Tools.Tests -{ - [TestClass] - public class ScriptTypeFactoryExtensionsTests - { - Mock factoryMock; - IScriptTypeFactory factoryObject; - - [TestInitialize] - public void TestInitialize() - { - factoryMock = new Mock(MockBehavior.Strict); - factoryObject = factoryMock.Object; - } - - [TestMethod] - public void TryCreateIntegersAndText() - { - // Arrange - factoryMock.Setup(o => o.Create((int)0)).Returns((IScriptType) null); - factoryMock.Setup(o => o.Create((byte)0)).Returns((IScriptType)null); - factoryMock.Setup(o => o.Create((short)0)).Returns((IScriptType)null); - factoryMock.Setup(o => o.Create((long)0)).Returns((IScriptType)null); - factoryMock.Setup(o => o.Create('m')).Returns((IScriptType)null); - factoryMock.Setup(o => o.Create("foo")).Returns((IScriptType)null); - - // Act + Assert - Assert.IsTrue(factoryObject.TryCreate(0, out _)); - Assert.IsTrue(factoryObject.TryCreate(0, out _)); - Assert.IsTrue(factoryObject.TryCreate(0, out _)); - Assert.IsTrue(factoryObject.TryCreate(0, out _)); - Assert.IsTrue(factoryObject.TryCreate('m', out _)); - Assert.IsTrue(factoryObject.TryCreate("foo", out _)); - - // Assert - factoryMock.Verify(); - } - - [TestMethod] - public void TryCreateNulls() - { - // Arrange - factoryMock.SetupGet(o => o.Null) - .Returns((IScriptType)null); - - // Act + Assert - Assert.IsTrue(factoryObject.TryCreate(null, out _)); - Assert.IsTrue(factoryObject.TryCreate>(null, out _)); - Assert.IsTrue(factoryObject.TryCreate>(null, out _)); - - // Assert - factoryMock.VerifyGet(o => o.Null, Times.Exactly(3)); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void TryCreateTrue() - { - // Arrange - factoryMock.SetupGet(o => o.True) - .Returns((IScriptType)null); - - // Act + Assert - Assert.IsTrue(factoryObject.TryCreate(true, out _)); - - // Assert - factoryMock.VerifyGet(o => o.True, Times.Once); - factoryMock.VerifyNoOtherCalls(); - } - - [TestMethod] - public void TryCreateFalse() - { - // Arrange - factoryMock.SetupGet(o => o.False) - .Returns((IScriptType) null); - - // Act + Assert - Assert.IsTrue(factoryObject.TryCreate(false, out _)); - - // Assert - factoryMock.VerifyGet(o => o.False, Times.Once); - factoryMock.VerifyNoOtherCalls(); - } - - [DataTestMethod] - [DataRow(1 + double.Epsilon, 1, typeof(IntegerBase))] - [DataRow(150, 150, typeof(IntegerBase))] - [DataRow(0.1+0.2, 0.3, typeof(DoubleBase))] - [DataRow(1e5+double.Epsilon, 1e5, typeof(IntegerBase))] - [DataRow(1e5+1e-5, 1e5+1e-5, typeof(DoubleBase))] - public void CreateAppropriateDoubleSimple(double input, double expectedValue, Type expectedType) - { - // Arrange - factoryMock.Setup(o => o.Create(It.IsAny())) - .Returns(d => new Mock(null, d).Object); - factoryMock.Setup(o => o.Create(It.IsAny())) - .Returns(i => new Mock(null, i).Object); - - // Act - IScriptType result = factoryObject.CreateAppropriate(input); - - // Assert - Assert.IsNotNull(result); - Assert.IsInstanceOfType(result, expectedType); - if (result is DoubleBase db) - Assert.AreEqual(expectedValue, db.Value, 1e-10); - if (result is IntegerBase ib) - Assert.AreEqual(expectedValue, ib.Value); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Tools/AutoObject/AutoValueBase.cs b/src/Mellis.Tools/AutoObject/AutoValueBase.cs deleted file mode 100644 index 87c6eca..0000000 --- a/src/Mellis.Tools/AutoObject/AutoValueBase.cs +++ /dev/null @@ -1,252 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using Mellis.Core.Interfaces; -using Mellis.Tools.Extensions; - -namespace Mellis.Tools.AutoObject -{ - public abstract class AutoValueBase : IScriptType - { - public IProcessor Processor { get; set; } - - public abstract IScriptType GetTypeDef(); - - public abstract string GetTypeName(); - - public abstract IScriptType Invoke(IScriptType[] arguments); - - public virtual IScriptType GetIndex(IScriptType index) - { - throw new NotImplementedException("Can't let you do that john."); - } - - public IScriptType SetIndex(IScriptType index, IScriptType value) - { - throw new NotImplementedException("Can't let you do that john."); - } - - public IScriptType GetProperty(string property) - { - foreach (MemberInfo memberInfo in GetMembers()) - { - var attribute = memberInfo.GetCustomAttribute(true); - if (attribute == null) continue; - if ((attribute.Name ?? memberInfo.Name) != property) continue; - - switch (memberInfo) - { - // found it - case PropertyInfo prop when Processor.Factory.TryCreate(prop.GetValue(this), out IScriptType value): - return value; - case FieldInfo field when Processor.Factory.TryCreate(field.GetValue(this), out IScriptType value): - return value; - - case FieldInfo field: - throw new NotImplementedException( - $"Type mismatch. Cannot get script version of {field.FieldType.Name}"); - case PropertyInfo prop: - throw new NotImplementedException( - $"Type mismatch. Cannot get script version of {prop.PropertyType.Name}"); - } - } - - return Processor.Factory.Null; - } - - public IScriptType SetProperty(string property, IScriptType value) - { - foreach (MemberInfo memberInfo in GetMembers()) - { - var attribute = memberInfo.GetCustomAttribute(true); - if (attribute == null) continue; - if ((attribute.Name ?? memberInfo.Name) != property) continue; - - switch (memberInfo) - { - // found it - case PropertyInfo prop when value.TryConvert(prop.PropertyType, out object clrValue): - prop.SetValue(this, clrValue); - return value; - case FieldInfo field when value.TryConvert(field.FieldType, out object clrValue): - field.SetValue(this, clrValue); - return value; - - case FieldInfo field: - throw new NotImplementedException($"Type mismatch. Cannot assign to {field.FieldType.Name}"); - case PropertyInfo prop: - throw new NotImplementedException($"Type mismatch. Cannot assign to {prop.PropertyType.Name}"); - } - } - - throw new NotImplementedException($"Property {property} not found"); - } - - private IEnumerable GetMembers() - { - return GetType().GetMembers(BindingFlags.Instance | - BindingFlags.FlattenHierarchy | - BindingFlags.GetField | - BindingFlags.GetProperty | - BindingFlags.Public | - BindingFlags.NonPublic - ); - } - - public bool TryConvert(out T value) - { - if (this is T v) - { - value = v; - return true; - } - - value = default; - return false; - } - - public bool TryConvert(Type type, out object value) - { - if (GetType() == type) - { - value = this; - return true; - } - - value = default; - return false; - } - - public bool IsTruthy() - { - throw new NotImplementedException(); - } - - public IScriptType ArithmeticUnaryPositive() - { - throw new NotImplementedException(); - } - - public IScriptType ArithmeticUnaryNegative() - { - throw new NotImplementedException(); - } - - public IScriptType ArithmeticAdd(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType ArithmeticSubtract(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType ArithmeticMultiply(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType ArithmeticDivide(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType ArithmeticModulus(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType ArithmeticExponent(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType ArithmeticFloorDivide(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType CompareEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType CompareNotEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType CompareGreaterThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType CompareGreaterThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType CompareLessThan(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType CompareLessThanOrEqual(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType BinaryNot() - { - throw new NotImplementedException(); - } - - public IScriptType BinaryAnd(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType BinaryOr(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType BinaryXor(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType BinaryLeftShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType BinaryRightShift(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType MemberIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - public IScriptType MemberNotIn(IScriptType lhs) - { - throw new NotImplementedException(); - } - - public IScriptType IdentityIs(IScriptType rhs) - { - throw new NotImplementedException(); - } - - public IScriptType IdentityIsNot(IScriptType rhs) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/src/Mellis.Tools/AutoObject/ShowInScriptAttribute.cs b/src/Mellis.Tools/AutoObject/ShowInScriptAttribute.cs deleted file mode 100644 index 76a8296..0000000 --- a/src/Mellis.Tools/AutoObject/ShowInScriptAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Mellis.Tools.AutoObject -{ - [AttributeUsage(AttributeTargets.Field | - AttributeTargets.Method | - AttributeTargets.Property)] - public class ShowInScriptAttribute : Attribute - { - public string Name; - } -} \ No newline at end of file diff --git a/src/Mellis.Tools/Extensions/ScriptTypeFactoryExtensions.cs b/src/Mellis.Tools/Extensions/ScriptTypeFactoryExtensions.cs deleted file mode 100644 index 8a37cef..0000000 --- a/src/Mellis.Tools/Extensions/ScriptTypeFactoryExtensions.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Mellis.Core.Interfaces; - -namespace Mellis.Tools.Extensions -{ - public static class ScriptTypeFactoryExtensions - { - public static bool TryCreate(this IScriptTypeFactory factory, T clrValue, out IScriptType scriptTypeValue) - { - if (clrValue == null) - { - scriptTypeValue = factory.Null; - return true; - } - - switch (clrValue) - { - case bool v: - scriptTypeValue = v ? factory.True : factory.False; - return true; - - case int v: - scriptTypeValue = factory.Create(v); - return true; - - case short v: - scriptTypeValue = factory.Create(v); - return true; - - case byte v: - scriptTypeValue = factory.Create(v); - return true; - - case long v: - scriptTypeValue = factory.Create(v); - return true; - - case char v: - scriptTypeValue = factory.Create(v); - return true; - - case string v: - scriptTypeValue = factory.Create(v); - return true; - - case IList v: - scriptTypeValue = factory.Create(v); - return true; - - case IDictionary v: - scriptTypeValue = factory.Create(v); - return true; - - case IFunction v: - scriptTypeValue = factory.Create(v); - return true; - - default: - scriptTypeValue = default; - return false; - } - } - - public static IScriptType CreateAppropriate(this IScriptTypeFactory factory, double value) - { - if (Math.Abs(value) % 1 <= 1e-10) - return factory.Create((int)Math.Round(value)); - - return factory.Create(value); - } - } -} diff --git a/src/Mellis.Tools/Mellis.Tools.csproj b/src/Mellis.Tools/Mellis.Tools.csproj deleted file mode 100644 index 9b6c968..0000000 --- a/src/Mellis.Tools/Mellis.Tools.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - netstandard2.0 - latest - - - - - - - diff --git a/src/Mellis.sln b/src/Mellis.sln deleted file mode 100644 index e80e7d6..0000000 --- a/src/Mellis.sln +++ /dev/null @@ -1,93 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.329 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mellis", "Mellis\Mellis.csproj", "{6D2CEC4F-EFF7-420E-A6A6-6E951F6752C8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Languages", "Languages", "{CED85FF5-60E1-48F7-B5CC-CBB5D71C50E6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mellis.Lang.Python3", "Mellis.Lang.Python3\Mellis.Lang.Python3.csproj", "{51109273-1F11-4B8C-A97E-9313BF620BE3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mellis.Core", "Mellis.Core\Mellis.Core.csproj", "{A5F7FF96-241D-4397-98FE-154DE7751AA6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mellis.Tools", "Mellis.Tools\Mellis.Tools.csproj", "{E426E557-499A-47BF-BC4C-6F56C2B21C2C}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{9DAE76BF-ADDC-4A2B-9CE9-035C924E23BA}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6F01D6A2-95D0-427D-93F5-377B3A07BFC5}" - ProjectSection(SolutionItems) = preProject - ..\.gitignore = ..\.gitignore - MSTestSettings.runsettings = MSTestSettings.runsettings - ..\NOTICE.md = ..\NOTICE.md - ..\README.md = ..\README.md - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mellis.Tools.Tests", "Mellis.Tools.Tests\Mellis.Tools.Tests.csproj", "{AA3C09C5-9C52-4A6E-8E49-F79DE61BC0B7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mellis.Lang.Base", "Mellis.Lang.Base\Mellis.Lang.Base.csproj", "{2076FE8C-82BE-40F4-A37D-704085830192}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mellis.Lang.Base.Tests", "Mellis.Lang.Base.Tests\Mellis.Lang.Base.Tests.csproj", "{F5A86ED3-9A20-4FD8-A400-12CB242FC525}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mellis.Lang.Python3.Tests", "Mellis.Lang.Python3.Tests\Mellis.Lang.Python3.Tests.csproj", "{DFFAA98E-A73D-470F-A00C-0DC0588F83CD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mellis.Core.Tests", "Mellis.Core.Tests\Mellis.Core.Tests.csproj", "{F7A039FB-830D-4201-B289-EAAC2D766DC8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6D2CEC4F-EFF7-420E-A6A6-6E951F6752C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D2CEC4F-EFF7-420E-A6A6-6E951F6752C8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6D2CEC4F-EFF7-420E-A6A6-6E951F6752C8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6D2CEC4F-EFF7-420E-A6A6-6E951F6752C8}.Release|Any CPU.Build.0 = Release|Any CPU - {51109273-1F11-4B8C-A97E-9313BF620BE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {51109273-1F11-4B8C-A97E-9313BF620BE3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {51109273-1F11-4B8C-A97E-9313BF620BE3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {51109273-1F11-4B8C-A97E-9313BF620BE3}.Release|Any CPU.Build.0 = Release|Any CPU - {A5F7FF96-241D-4397-98FE-154DE7751AA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A5F7FF96-241D-4397-98FE-154DE7751AA6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A5F7FF96-241D-4397-98FE-154DE7751AA6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A5F7FF96-241D-4397-98FE-154DE7751AA6}.Release|Any CPU.Build.0 = Release|Any CPU - {E426E557-499A-47BF-BC4C-6F56C2B21C2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E426E557-499A-47BF-BC4C-6F56C2B21C2C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E426E557-499A-47BF-BC4C-6F56C2B21C2C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E426E557-499A-47BF-BC4C-6F56C2B21C2C}.Release|Any CPU.Build.0 = Release|Any CPU - {AA3C09C5-9C52-4A6E-8E49-F79DE61BC0B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AA3C09C5-9C52-4A6E-8E49-F79DE61BC0B7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AA3C09C5-9C52-4A6E-8E49-F79DE61BC0B7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AA3C09C5-9C52-4A6E-8E49-F79DE61BC0B7}.Release|Any CPU.Build.0 = Release|Any CPU - {2076FE8C-82BE-40F4-A37D-704085830192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2076FE8C-82BE-40F4-A37D-704085830192}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2076FE8C-82BE-40F4-A37D-704085830192}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2076FE8C-82BE-40F4-A37D-704085830192}.Release|Any CPU.Build.0 = Release|Any CPU - {F5A86ED3-9A20-4FD8-A400-12CB242FC525}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F5A86ED3-9A20-4FD8-A400-12CB242FC525}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F5A86ED3-9A20-4FD8-A400-12CB242FC525}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F5A86ED3-9A20-4FD8-A400-12CB242FC525}.Release|Any CPU.Build.0 = Release|Any CPU - {DFFAA98E-A73D-470F-A00C-0DC0588F83CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DFFAA98E-A73D-470F-A00C-0DC0588F83CD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DFFAA98E-A73D-470F-A00C-0DC0588F83CD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DFFAA98E-A73D-470F-A00C-0DC0588F83CD}.Release|Any CPU.Build.0 = Release|Any CPU - {F7A039FB-830D-4201-B289-EAAC2D766DC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F7A039FB-830D-4201-B289-EAAC2D766DC8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F7A039FB-830D-4201-B289-EAAC2D766DC8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F7A039FB-830D-4201-B289-EAAC2D766DC8}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {51109273-1F11-4B8C-A97E-9313BF620BE3} = {CED85FF5-60E1-48F7-B5CC-CBB5D71C50E6} - {A5F7FF96-241D-4397-98FE-154DE7751AA6} = {9DAE76BF-ADDC-4A2B-9CE9-035C924E23BA} - {2076FE8C-82BE-40F4-A37D-704085830192} = {CED85FF5-60E1-48F7-B5CC-CBB5D71C50E6} - {F5A86ED3-9A20-4FD8-A400-12CB242FC525} = {CED85FF5-60E1-48F7-B5CC-CBB5D71C50E6} - {DFFAA98E-A73D-470F-A00C-0DC0588F83CD} = {CED85FF5-60E1-48F7-B5CC-CBB5D71C50E6} - {F7A039FB-830D-4201-B289-EAAC2D766DC8} = {9DAE76BF-ADDC-4A2B-9CE9-035C924E23BA} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {FA74885F-76C3-4E43-9A4C-C83A58CD986B} - EndGlobalSection -EndGlobal diff --git a/src/Mellis/ClrFunction.cs b/src/Mellis/ClrFunction.cs deleted file mode 100644 index 14b6066..0000000 --- a/src/Mellis/ClrFunction.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Core.Interfaces; - -namespace Mellis -{ - public abstract class ClrFunctionBase : IFunction - { - #region Predefined properties - - public IProcessor Processor { get; set; } - - public SourceReference Source { get; } = SourceReference.ClrSource; - - #endregion - - #region Abstract properties - - public abstract string Name { get; } - - public abstract string Description { get; } - - public abstract IScriptType Invoke(IScriptType[] arguments); - - #endregion - } -} \ No newline at end of file diff --git a/src/Mellis/Mellis.csproj b/src/Mellis/Mellis.csproj deleted file mode 100644 index 1859272..0000000 --- a/src/Mellis/Mellis.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - netstandard2.0 - 2.0.0 - Zifro AB - Zifro AB - Zifro Playground Compiler - latest - - - - - - - diff --git a/src/Mellis/Proxies/ProxyBase.cs b/src/Mellis/Proxies/ProxyBase.cs deleted file mode 100644 index cd6869e..0000000 --- a/src/Mellis/Proxies/ProxyBase.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using Mellis.Core.Interfaces; - -namespace Mellis.Proxies -{ - public abstract class ProxyBase : IScriptType - { - protected IScriptType InnerValue; - - protected ProxyBase(IScriptType innerValue) - { - InnerValue = innerValue; - } - - public IProcessor Processor => InnerValue.Processor; - public IScriptType GetTypeDef() => InnerValue.GetTypeDef(); - public string GetTypeName() => InnerValue.GetTypeName(); - public bool IsTruthy() => InnerValue.IsTruthy(); - public IScriptType Invoke(IScriptType[] arguments) => InnerValue.Invoke(arguments); - public IScriptType GetIndex(IScriptType index) => InnerValue.GetIndex(index); - public IScriptType SetIndex(IScriptType index, IScriptType value) => InnerValue.SetIndex(index, value); - public IScriptType GetProperty(string property) => InnerValue.GetProperty(property); - public IScriptType SetProperty(string property, IScriptType value) => InnerValue.SetProperty(property, value); - public bool TryConvert(out T value) => InnerValue.TryConvert(out value); - public bool TryConvert(Type type, out object value) => InnerValue.TryConvert(type, out value); - public IScriptType ArithmeticUnaryPositive() => InnerValue.ArithmeticUnaryPositive(); - public IScriptType ArithmeticUnaryNegative() => InnerValue.ArithmeticUnaryNegative(); - public IScriptType ArithmeticAdd(IScriptType rhs) => InnerValue.ArithmeticAdd(rhs); - public IScriptType ArithmeticSubtract(IScriptType rhs) => InnerValue.ArithmeticSubtract(rhs); - public IScriptType ArithmeticMultiply(IScriptType rhs) => InnerValue.ArithmeticMultiply(rhs); - public IScriptType ArithmeticDivide(IScriptType rhs) => InnerValue.ArithmeticDivide(rhs); - public IScriptType ArithmeticModulus(IScriptType rhs) => InnerValue.ArithmeticModulus(rhs); - public IScriptType ArithmeticExponent(IScriptType rhs) => InnerValue.ArithmeticExponent(rhs); - public IScriptType ArithmeticFloorDivide(IScriptType rhs) => InnerValue.ArithmeticFloorDivide(rhs); - public IScriptType CompareEqual(IScriptType rhs) => InnerValue.CompareEqual(rhs); - public IScriptType CompareNotEqual(IScriptType rhs) => InnerValue.CompareNotEqual(rhs); - public IScriptType CompareGreaterThan(IScriptType rhs) => InnerValue.CompareGreaterThan(rhs); - public IScriptType CompareGreaterThanOrEqual(IScriptType rhs) => InnerValue.CompareGreaterThanOrEqual(rhs); - public IScriptType CompareLessThan(IScriptType rhs) => InnerValue.CompareLessThan(rhs); - public IScriptType CompareLessThanOrEqual(IScriptType rhs) => InnerValue.CompareLessThanOrEqual(rhs); - public IScriptType BinaryNot() => InnerValue.BinaryNot(); - public IScriptType BinaryAnd(IScriptType rhs) => InnerValue.BinaryAnd(rhs); - public IScriptType BinaryOr(IScriptType rhs) => InnerValue.BinaryOr(rhs); - public IScriptType BinaryXor(IScriptType rhs) => InnerValue.BinaryXor(rhs); - public IScriptType BinaryLeftShift(IScriptType rhs) => InnerValue.BinaryLeftShift(rhs); - public IScriptType BinaryRightShift(IScriptType rhs) => InnerValue.BinaryRightShift(rhs); - public IScriptType MemberIn(IScriptType lhs) => InnerValue.MemberIn(lhs); - public IScriptType MemberNotIn(IScriptType lhs) => InnerValue.MemberNotIn(lhs); - public IScriptType IdentityIs(IScriptType rhs) => InnerValue.IdentityIs(rhs); - public IScriptType IdentityIsNot(IScriptType rhs) => InnerValue.IdentityIsNot(rhs); - } -} diff --git a/src/Mellis/Proxies/ReturnValue.cs b/src/Mellis/Proxies/ReturnValue.cs deleted file mode 100644 index 524c14a..0000000 --- a/src/Mellis/Proxies/ReturnValue.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Mellis.Core.Interfaces; - -namespace Mellis.Proxies -{ - public class ReturnValue : ProxyBase - { - /// - /// Gets the function from which this value was retrieved. - /// - public IFunction Function { get; } - - public ReturnValue(IScriptType innerValue, IFunction function) - : base(innerValue) - { - Function = function; - } - } -} \ No newline at end of file diff --git a/src/Mellis/Proxies/Variable.cs b/src/Mellis/Proxies/Variable.cs deleted file mode 100644 index b69859d..0000000 --- a/src/Mellis/Proxies/Variable.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Mellis.Core.Entities; -using Mellis.Core.Interfaces; - -namespace Mellis.Proxies -{ - public class Variable : ProxyBase - { - /// - /// Gets the name of the declared variable. - /// - public string Name { get; } - - /// - /// Gets the source of where the variable was declared. - /// - public SourceReference Source { get; } - - /// - /// Gets whether or not this variable was declared in the CLR or in the script environment. - /// - public bool IsFromClr { get; } - - /// The inner value to wrap. - /// Name of the declared variable. - /// Source of where the variable was declared. - /// Whether or not this variable was declared in the CLR or in the script environment. - public Variable(IScriptType innerValue, string name, SourceReference source, bool isClr) - : base(innerValue) - { - Name = name; - Source = source; - IsFromClr = isClr; - } - } -} \ No newline at end of file