├── .gitattributes
├── .github
└── workflows
│ └── dotnet.yml
├── .gitignore
├── AUTHORS
├── LICENSE
├── README.md
└── src
├── README.md
├── Tutorial
└── Tutorials
│ ├── App.config
│ ├── Chapters
│ ├── Chapter1.cs
│ ├── Chapter10.cs
│ ├── Chapter11.cs
│ ├── Chapter12.cs
│ ├── Chapter2.cs
│ ├── Chapter3.cs
│ ├── Chapter4.cs
│ ├── Chapter5.cs
│ ├── Chapter6.cs
│ ├── Chapter7.cs
│ ├── Chapter8.cs
│ ├── Chapter9.cs
│ └── X1.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Scripts
│ └── Test.lua
│ ├── TutorialAttribute.cs
│ ├── Tutorials.csproj
│ └── readme.md
├── WattleScript.Hardwire
├── Generators
│ ├── ArrayMemberDescriptorGenerator.cs
│ ├── Base
│ │ └── AssignableMemberDescriptorGeneratorBase.cs
│ ├── DynValueMemberDescriptorGenerator.cs
│ ├── FieldMemberDescriptorGenerator.cs
│ ├── MethodMemberDescriptorGenerator.cs
│ ├── NullGenerator.cs
│ ├── OverloadedMethodMemberDescriptorGenerator.cs
│ ├── PropertyMemberDescriptorGenerator.cs
│ ├── StandardUserDataDescriptorGenerator.cs
│ └── ValueTypeDefaultCtorMemberDescriptorGenerator.cs
├── HardwireCodeGenerationContext.cs
├── HardwireGenerator.cs
├── HardwireGeneratorRegistry.cs
├── ICodeGenerationLogger.cs
├── IHardwireGenerator.cs
├── IdGen.cs
├── Languages
│ ├── CSharpHardwireCodeGenerationLanguage.cs
│ ├── HardwireCodeGenerationLanguage.cs
│ └── VbHardwireCodeGenerationLanguage.cs
├── Utils
│ ├── GeneratorUtilities.cs
│ └── HardwireParameterDescriptor.cs
└── WattleScript.Hardwire.csproj
├── WattleScript.HardwireGen.Test
├── ExtraHardwire.xml
├── GenericExtra.cs
├── MyWattleData.cs
├── SanityTest.cs
├── WattleScript.HardwireGen.Test.csproj
└── WithProperty.cs
├── WattleScript.HardwireGen
├── ClassNames.cs
├── ExtraClassListXml.cs
├── HardwireInterop.cs
├── HardwireModel.cs
├── HardwireSourceGenerator.cs
├── IdGen.cs
├── Properties
│ └── launchSettings.json
├── StringUtils.cs
├── SymbolUtils.cs
├── Utilities
│ ├── EquatableArray.cs
│ ├── Polyfill.cs
│ └── TabbedWriter.cs
└── WattleScript.HardwireGen.csproj
├── WattleScript.Interpreter.Tests
├── EndToEnd
│ ├── AsyncTests.cs
│ ├── BinaryDumpTests.cs
│ ├── CLike
│ │ ├── SyntaxCLike
│ │ │ ├── Access
│ │ │ │ ├── 01-private-field.lua
│ │ │ │ ├── 01-private-field.txt
│ │ │ │ ├── 02-private-nowrite-invalid.lua
│ │ │ │ ├── 03-private-thisaccess.lua
│ │ │ │ ├── 03-private-thisaccess.txt
│ │ │ │ ├── 04-private-base.lua
│ │ │ │ ├── 04-private-base.txt
│ │ │ │ ├── 05-private-mixin.lua
│ │ │ │ ├── 05-private-mixin.txt
│ │ │ │ ├── 06-privatestatic-invalid.lua
│ │ │ │ ├── 07-public.lua
│ │ │ │ ├── 07-public.txt
│ │ │ │ └── 08-conflicting-access-invalid.lua
│ │ │ ├── Aliases
│ │ │ │ ├── 1-null.lua
│ │ │ │ ├── 1-null.txt
│ │ │ │ ├── 2-this.lua
│ │ │ │ └── 2-this.txt
│ │ │ ├── Annotations
│ │ │ │ ├── 1-annotation.lua
│ │ │ │ ├── 1-annotation.txt
│ │ │ │ ├── 2-annotation.lua
│ │ │ │ ├── 2-annotation.txt
│ │ │ │ ├── 3-annotation.lua
│ │ │ │ ├── 3-annotation.txt
│ │ │ │ ├── 4-annotation.lua
│ │ │ │ ├── 4-annotation.txt
│ │ │ │ ├── 5-annotation.lua
│ │ │ │ └── 5-annotation.txt
│ │ │ ├── Classes
│ │ │ │ ├── 0-new.lua
│ │ │ │ ├── 0-new.txt
│ │ │ │ ├── 1-classloop.lua
│ │ │ │ ├── 1-classloop.txt
│ │ │ │ ├── 10-static-field-ref.lua
│ │ │ │ ├── 10-static-field-ref.txt
│ │ │ │ ├── 11-duplicate-function-invalid.lua
│ │ │ │ ├── 11-duplicate-function-invalid.txt
│ │ │ │ ├── 12-duplicate-field-invalid.lua
│ │ │ │ ├── 12-duplicate-field-invalid.txt
│ │ │ │ ├── 13-reserved-field-invalid.lua
│ │ │ │ ├── 13-reserved-field-invalid.txt
│ │ │ │ ├── 14-static-math.lua
│ │ │ │ ├── 14-static-math.txt
│ │ │ │ ├── 15-static-class-empty.lua
│ │ │ │ ├── 15-static-class-empty.txt
│ │ │ │ ├── 16-static-class-empty-invalid.lua
│ │ │ │ ├── 17-static-class-non-static-field-invalid.lua
│ │ │ │ ├── 18-static-class-non-static-function-invalid.lua
│ │ │ │ ├── 19-static-class-non-static-function-arrow-invalid.lua
│ │ │ │ ├── 2-mixin.lua
│ │ │ │ ├── 2-mixin.txt
│ │ │ │ ├── 20-static-class-ctor-invalid.lua
│ │ │ │ ├── 21-static-class-ctor-static-invalid.lua
│ │ │ │ ├── 22-class-lhs-new.lua
│ │ │ │ ├── 22-class-lhs-new.txt
│ │ │ │ ├── 23-static-class-instantiate-invalid.lua
│ │ │ │ ├── 24-static-class-base-invalid.lua
│ │ │ │ ├── 25-static-class-static-field-function-ref.lua
│ │ │ │ ├── 25-static-class-static-field-function-ref.txt
│ │ │ │ ├── 26-class-field-thiscall.lua
│ │ │ │ ├── 26-class-field-thiscall.txt
│ │ │ │ ├── 27-class-field-thiscall-function.lua
│ │ │ │ ├── 27-class-field-thiscall-function.txt
│ │ │ │ ├── 28-class-sealed-invalid.lua
│ │ │ │ ├── 29-class-sealed.lua
│ │ │ │ ├── 29-class-sealed.txt
│ │ │ │ ├── 3-basecall.lua
│ │ │ │ ├── 3-basecall.txt
│ │ │ │ ├── 4-baseconstruct.lua
│ │ │ │ ├── 4-baseconstruct.txt
│ │ │ │ ├── 5-baseconstruct-default.lua
│ │ │ │ ├── 5-baseconstruct-default.txt
│ │ │ │ ├── 6-baseclass-invalid.lua
│ │ │ │ ├── 6-baseclass-invalid.txt
│ │ │ │ ├── 7-static.lua
│ │ │ │ ├── 7-static.txt
│ │ │ │ ├── 8-static-local-ref.lua
│ │ │ │ ├── 8-static-local-ref.txt
│ │ │ │ ├── 9-static-field.lua
│ │ │ │ └── 9-static-field.txt
│ │ │ ├── Enums
│ │ │ │ ├── 0-enum.lua
│ │ │ │ ├── 0-enum.txt
│ │ │ │ ├── 1-selfref.lua
│ │ │ │ ├── 1-selfref.txt
│ │ │ │ ├── 2-annotsyntax.lua
│ │ │ │ └── 2-annotsyntax.txt
│ │ │ ├── Errors
│ │ │ │ ├── 1-common-invalid.lua
│ │ │ │ ├── 1-common-invalid.txt
│ │ │ │ ├── 2-resync-invalid.lua
│ │ │ │ └── 2-resync-invalid.txt
│ │ │ ├── Functions
│ │ │ │ ├── 1-call.lua
│ │ │ │ ├── 1-call.txt
│ │ │ │ ├── 10-call-default-scope-local-3.lua
│ │ │ │ ├── 10-call-default-scope-local-3.txt
│ │ │ │ ├── 11-call-default-scope-arrow.lua
│ │ │ │ ├── 11-call-default-scope-arrow.txt
│ │ │ │ ├── 12-call-default-scope-arrow-invalid.lua
│ │ │ │ ├── 12-call-default-scope-arrow-invalid.txt
│ │ │ │ ├── 13-call-default-scope-arrow-arrow.lua
│ │ │ │ ├── 13-call-default-scope-arrow-arrow.txt
│ │ │ │ ├── 14-call-default-scope-arrow-arrow-default.lua
│ │ │ │ ├── 14-call-default-scope-arrow-arrow-default.txt
│ │ │ │ ├── 15-call-default-scope-arrow-arrow-default-2.lua
│ │ │ │ ├── 15-call-default-scope-arrow-arrow-default-2.txt
│ │ │ │ ├── 16-default-call-closure.lua
│ │ │ │ ├── 16-default-call-closure.txt
│ │ │ │ ├── 17-call-hoisted.lua
│ │ │ │ ├── 17-call-hoisted.txt
│ │ │ │ ├── 18-assign-lambda.lua
│ │ │ │ ├── 18-assign-lambda.txt
│ │ │ │ ├── 2-call-default.lua
│ │ │ │ ├── 2-call-default.txt
│ │ │ │ ├── 3-call-default-invalid.lua
│ │ │ │ ├── 3-call-default-invalid.txt
│ │ │ │ ├── 4-call-default-2.lua
│ │ │ │ ├── 4-call-default-2.txt
│ │ │ │ ├── 5-call-default-3.lua
│ │ │ │ ├── 5-call-default-3.txt
│ │ │ │ ├── 6-call-default-local.lua
│ │ │ │ ├── 6-call-default-local.txt
│ │ │ │ ├── 7-call-default-scope.lua
│ │ │ │ ├── 7-call-default-scope.txt
│ │ │ │ ├── 8-call-default-scope-local.lua
│ │ │ │ ├── 8-call-default-scope-local.txt
│ │ │ │ ├── 9-call-default-scope-local-2.lua
│ │ │ │ └── 9-call-default-scope-local-2.txt
│ │ │ ├── Meta
│ │ │ │ ├── 0-string.lua
│ │ │ │ ├── 0-string.txt
│ │ │ │ ├── 1-number.lua
│ │ │ │ ├── 1-number.txt
│ │ │ │ ├── 2-boolean.lua
│ │ │ │ ├── 2-boolean.txt
│ │ │ │ ├── 3-table.lua
│ │ │ │ ├── 3-table.txt
│ │ │ │ ├── 4-range.lua
│ │ │ │ └── 4-range.txt
│ │ │ ├── Operators
│ │ │ │ ├── 0-null-coalescing-assignment-min.lua
│ │ │ │ ├── 0-null-coalescing-assignment-min.txt
│ │ │ │ ├── 1-null-coalescing-assignment-check.lua
│ │ │ │ ├── 1-null-coalescing-assignment-check.txt
│ │ │ │ ├── 10-relax-ternary-chain-2.lua
│ │ │ │ ├── 10-relax-ternary-chain-2.txt
│ │ │ │ ├── 11-nill-coalescing-inverse.lua
│ │ │ │ ├── 11-nill-coalescing-inverse.txt
│ │ │ │ ├── 12-nill-coalescing-assignment-inverse.lua
│ │ │ │ ├── 12-nill-coalescing-assignment-inverse.txt
│ │ │ │ ├── 13-nill-coalescing-assignment-inverse-ok.lua
│ │ │ │ ├── 13-nill-coalescing-assignment-inverse-ok.txt
│ │ │ │ ├── 14-length.lua
│ │ │ │ ├── 14-length.txt
│ │ │ │ ├── 16-for-range-exclusive.lua
│ │ │ │ ├── 16-for-range-exclusive.txt
│ │ │ │ ├── 17-for-range-tbl-one-side.lua
│ │ │ │ ├── 17-for-range-tbl-one-side.txt
│ │ │ │ ├── 18-range-var.lua
│ │ │ │ ├── 18-range-var.txt
│ │ │ │ ├── 19-range-var-print.lua
│ │ │ │ ├── 19-range-var-print.txt
│ │ │ │ ├── 2-null-coalescing-assignment-scope.lua
│ │ │ │ ├── 2-null-coalescing-assignment-scope.txt
│ │ │ │ ├── 20-range-var-set.lua
│ │ │ │ ├── 20-range-var-set.txt
│ │ │ │ ├── 3-null-coalescing-assignment-local.lua
│ │ │ │ ├── 3-null-coalescing-assignment-local.txt
│ │ │ │ ├── 4-null-coalescing-assignment-local-scope.lua
│ │ │ │ ├── 4-null-coalescing-assignment-local-scope.txt
│ │ │ │ ├── 5-null-coalescing-assignment-ternary-skip.lua
│ │ │ │ ├── 5-null-coalescing-assignment-ternary-skip.txt
│ │ │ │ ├── 6-null-coalescing-assignment-ternary-exec.lua
│ │ │ │ ├── 6-null-coalescing-assignment-ternary-exec.txt
│ │ │ │ ├── 7-relax-ternary.lua
│ │ │ │ ├── 7-relax-ternary.txt
│ │ │ │ ├── 8-relax-ternary-cmp.lua
│ │ │ │ ├── 8-relax-ternary-cmp.txt
│ │ │ │ ├── 9-relax-ternary-chain.lua
│ │ │ │ └── 9-relax-ternary-chain.txt
│ │ │ ├── Preprocessor
│ │ │ │ ├── 0-linesanity.lua
│ │ │ │ ├── 0-linesanity.txt
│ │ │ │ ├── 1-ifdef.lua
│ │ │ │ ├── 1-ifdef.txt
│ │ │ │ ├── 10-isdefined.lua
│ │ │ │ ├── 10-isdefined.txt
│ │ │ │ ├── 11-coloffset.lua
│ │ │ │ ├── 11-coloffset.txt
│ │ │ │ ├── 2-ifndef.lua
│ │ │ │ ├── 2-ifndef.txt
│ │ │ │ ├── 3-in-string.lua
│ │ │ │ ├── 3-in-string.txt
│ │ │ │ ├── 4-and.lua
│ │ │ │ ├── 4-and.txt
│ │ │ │ ├── 5-ops.lua
│ │ │ │ ├── 5-ops.txt
│ │ │ │ ├── 6-simpleline.lua
│ │ │ │ ├── 6-simpleline.txt
│ │ │ │ ├── 7-values.lua
│ │ │ │ ├── 7-values.txt
│ │ │ │ ├── 9-multidef.lua
│ │ │ │ └── 9-multidef.txt
│ │ │ ├── Ranges
│ │ │ │ ├── 1-for-range-inclusive.lua
│ │ │ │ ├── 1-for-range-inclusive.txt
│ │ │ │ ├── 10-range-tbl-index.lua
│ │ │ │ ├── 10-range-tbl-index.txt
│ │ │ │ ├── 11-range-tbl-index-mixed.lua
│ │ │ │ ├── 11-range-tbl-index-mixed.txt
│ │ │ │ ├── 12-range-concat-invalid.lua
│ │ │ │ ├── 12-range-concat-invalid.txt
│ │ │ │ ├── 13-range-tbl-add.lua
│ │ │ │ ├── 13-range-tbl-add.txt
│ │ │ │ ├── 14-range-inline-add-invalid.lua
│ │ │ │ ├── 14-range-inline-add-invalid.txt
│ │ │ │ ├── 15-range-multiple-vars.lua
│ │ │ │ ├── 15-range-multiple-vars.txt
│ │ │ │ ├── 16-range-iter-ref.lua
│ │ │ │ ├── 16-range-iter-ref.txt
│ │ │ │ ├── 17-range-vstack.lua
│ │ │ │ ├── 17-range-vstack.txt
│ │ │ │ ├── 18-range-tuple.lua
│ │ │ │ ├── 18-range-tuple.txt
│ │ │ │ ├── 19-range-numval-low.lua
│ │ │ │ ├── 19-range-numval-low.txt
│ │ │ │ ├── 2-for-range-left-exclusive.lua
│ │ │ │ ├── 2-for-range-left-exclusive.txt
│ │ │ │ ├── 20-range-var.lua
│ │ │ │ ├── 20-range-var.txt
│ │ │ │ ├── 21-range-string.lua
│ │ │ │ ├── 21-range-string.txt
│ │ │ │ ├── 22-range-string-direct.lua
│ │ │ │ ├── 22-range-string-direct.txt
│ │ │ │ ├── 23-range-bool-invalid.lua
│ │ │ │ ├── 23-range-bool-invalid.txt
│ │ │ │ ├── 24-range-string-invalid.lua
│ │ │ │ ├── 24-range-string-invalid.txt
│ │ │ │ ├── 3-for-range-right-exclusive.lua
│ │ │ │ ├── 3-for-range-right-exclusive.txt
│ │ │ │ ├── 4-for-range-exclusive.lua
│ │ │ │ ├── 4-for-range-exclusive.txt
│ │ │ │ ├── 5-range-var.lua
│ │ │ │ ├── 5-range-var.txt
│ │ │ │ ├── 6-range-set.lua
│ │ │ │ ├── 6-range-set.txt
│ │ │ │ ├── 7-range-get.lua
│ │ │ │ ├── 7-range-get.txt
│ │ │ │ ├── 8-range-chain.lua
│ │ │ │ ├── 8-range-chain.txt
│ │ │ │ ├── 9-range-ref.lua
│ │ │ │ └── 9-range-ref.txt
│ │ │ ├── Strings
│ │ │ │ ├── 1-interpolated-string.lua
│ │ │ │ ├── 1-interpolated-string.txt
│ │ │ │ ├── 10-unicode-auto.lua
│ │ │ │ ├── 10-unicode-auto.txt
│ │ │ │ ├── 11-unicode-transition-multiple.lua
│ │ │ │ ├── 11-unicode-transition-multiple.txt
│ │ │ │ ├── 11-unicode-transition.lua
│ │ │ │ ├── 11-unicode-transition.txt
│ │ │ │ ├── 12-unicode-auto-hex.lua
│ │ │ │ ├── 12-unicode-auto-hex.txt
│ │ │ │ ├── 13-unicode-auto-two-sequences.lua
│ │ │ │ ├── 13-unicode-auto-two-sequences.txt
│ │ │ │ ├── 14-unicode-auto-two-sequences-2.lua
│ │ │ │ ├── 14-unicode-auto-two-sequences-2.txt
│ │ │ │ ├── 15-unicode-mixed.lua
│ │ │ │ ├── 15-unicode-mixed.txt
│ │ │ │ ├── 2-interpolated-string-escape.lua
│ │ │ │ ├── 2-interpolated-string-escape.txt
│ │ │ │ ├── 3-interpolated-string-escape-backtick.lua
│ │ │ │ ├── 3-interpolated-string-escape-backtick.txt
│ │ │ │ ├── 4-interpolated-string-expr.lua
│ │ │ │ ├── 4-interpolated-string-expr.txt
│ │ │ │ ├── 5-interpolated-string-multiline.lua
│ │ │ │ ├── 5-interpolated-string-multiline.txt
│ │ │ │ ├── 6-interpolated-string-double.lua
│ │ │ │ ├── 6-interpolated-string-double.txt
│ │ │ │ ├── 7-interpolated-string-multiple.lua
│ │ │ │ ├── 7-interpolated-string-multiple.txt
│ │ │ │ ├── 8-unicode.lua
│ │ │ │ ├── 8-unicode.txt
│ │ │ │ ├── 9-unicode-brk.lua
│ │ │ │ └── 9-unicode-brk.txt
│ │ │ ├── Switch
│ │ │ │ ├── 0-switchbreak.lua
│ │ │ │ ├── 0-switchbreak.txt
│ │ │ │ ├── 1-multicaseswitch.lua
│ │ │ │ ├── 1-multicaseswitch.txt
│ │ │ │ ├── 2-gotocase.lua
│ │ │ │ ├── 2-gotocase.txt
│ │ │ │ ├── 3-gotodefault.lua
│ │ │ │ ├── 3-gotodefault.txt
│ │ │ │ ├── 4-multicaseswitch-brks.lua
│ │ │ │ └── 4-multicaseswitch-brks.txt
│ │ │ └── Tables
│ │ │ │ ├── 1-double-square-brk.lua
│ │ │ │ └── 1-double-square-brk.txt
│ │ └── SyntaxLua
│ │ │ └── Tables
│ │ │ ├── 0-set.lua
│ │ │ ├── 0-set.txt
│ │ │ ├── 01-set-double.lua
│ │ │ ├── 01-set-double.txt
│ │ │ ├── 1-iterate.lua
│ │ │ ├── 1-iterate.txt
│ │ │ ├── 10-concat-from-to.lua
│ │ │ ├── 10-concat-from-to.txt
│ │ │ ├── 2-insert.lua
│ │ │ ├── 2-insert.txt
│ │ │ ├── 3-sort-simple.lua
│ │ │ ├── 3-sort-simple.txt
│ │ │ ├── 4-remove.lua
│ │ │ ├── 4-remove.txt
│ │ │ ├── 5-remove-index.lua
│ │ │ ├── 5-remove-index.txt
│ │ │ ├── 6-remove-index-multiple.lua
│ │ │ ├── 6-remove-index-multiple.txt
│ │ │ ├── 7-concat.lua
│ │ │ ├── 7-concat.txt
│ │ │ ├── 8-concat-from.lua
│ │ │ └── 8-concat-from.txt
│ ├── CLikeTestRunner.cs
│ ├── CSyntaxTests.cs
│ ├── ClosureTests.cs
│ ├── CollectionsBaseGenRegisteredTests.cs
│ ├── CollectionsBaseInterfGenRegisteredTests.cs
│ ├── CollectionsRegisteredTests.cs
│ ├── ConfigPropertyAssignerTests.cs
│ ├── CoroutineTests.cs
│ ├── DynamicTests.cs
│ ├── ErrorHandlingTests.cs
│ ├── FunctionTests.cs
│ ├── GotoTests.cs
│ ├── JsonSerializationTests.cs
│ ├── LocalRedefTest.cs
│ ├── LuaTestSuiteExtract.cs
│ ├── MetatableTests.cs
│ ├── ProxyObjectsTests.cs
│ ├── SimpleTests.cs
│ ├── StringLibTests.cs
│ ├── StructAssignmentTechnique.cs
│ ├── TableTests.cs
│ ├── TailCallTests.cs
│ ├── UserDataEnumsTest.cs
│ ├── UserDataEventsTests.cs
│ ├── UserDataFieldsTests.cs
│ ├── UserDataIndexerTests.cs
│ ├── UserDataMetaTests.cs
│ ├── UserDataMethodsTests.cs
│ ├── UserDataNestedTypesTests.cs
│ ├── UserDataOverloadsTests.cs
│ ├── UserDataPropertiesTests.cs
│ ├── Utils.cs
│ ├── VarargsTupleTests.cs
│ ├── VtUserDataFieldsTests.cs
│ ├── VtUserDataIndexerTests.cs
│ ├── VtUserDataMetaTests.cs
│ ├── VtUserDataMethodsTests.cs
│ ├── VtUserDataOverloadsTests.cs
│ └── VtUserDataPropertiesTests.cs
├── TapRunner.cs
├── TestMore
│ ├── 000-sanity.t
│ ├── 001-if.t
│ ├── 002-table.t
│ ├── 011-while.t
│ ├── 012-repeat.t
│ ├── 014-fornum.t
│ ├── 015-forlist.t
│ ├── 101-boolean.t
│ ├── 102-function.t
│ ├── 103-nil.t
│ ├── 104-number.t
│ ├── 105-string.t
│ ├── 106-table.t
│ ├── 107-thread.t
│ ├── 108-userdata.t
│ ├── 200-examples.t
│ ├── 201-assign.t
│ ├── 202-expr.t
│ ├── 203-lexico.t
│ ├── 204-grammar.t
│ ├── 211-scope.t
│ ├── 212-function.t
│ ├── 213-closure.t
│ ├── 214-coroutine.t
│ ├── 221-table.t
│ ├── 222-constructor.t
│ ├── 223-iterator.t
│ ├── 231-metatable.t
│ ├── 232-object.t
│ ├── 301-basic.t
│ ├── 304-string.t
│ ├── 305-table.t
│ ├── 306-math.t
│ ├── 307-bit.t
│ ├── 308-io.t
│ ├── 309-os.t
│ ├── 310-debug.t
│ ├── 314-regex.t
│ ├── 320-stdin.t
│ ├── Makefile
│ ├── Modules
│ │ └── Test
│ │ │ ├── Builder.lua
│ │ │ └── More.lua
│ └── makefile.mak
├── TestMoreTests.cs
├── TestRunner.cs
├── TestScript.cs
└── WattleScript.Interpreter.Tests.csproj
├── WattleScript.Interpreter
├── CoreLib
│ ├── BasicModule.cs
│ ├── Bit32Module.cs
│ ├── CoroutineModule.cs
│ ├── DebugModule.cs
│ ├── DynamicModule.cs
│ ├── ErrorHandlingModule.cs
│ ├── IO
│ │ ├── BinaryEncoding.cs
│ │ ├── FileUserData.cs
│ │ ├── FileUserDataBase.cs
│ │ ├── StandardIOFileUserDataBase.cs
│ │ └── StreamFileUserDataBase.cs
│ ├── IoModule.cs
│ ├── JsonModule.cs
│ ├── LoadModule.cs
│ ├── MathModule.cs
│ ├── MetaTableModule.cs
│ ├── OsSystemModule.cs
│ ├── OsTimeModule.cs
│ ├── PrototypeModule.cs
│ ├── StringLib
│ │ ├── KopiLua_sprintf.cs
│ │ ├── PatternRegex.cs
│ │ └── StringRange.cs
│ ├── StringModule.cs
│ ├── TableIteratorsModule.cs
│ └── TableModule.cs
├── DataStructs
│ ├── Extension_Methods.cs
│ ├── FastStack.cs
│ ├── MultiDictionary.cs
│ ├── ReferenceEqualityComparer.cs
│ └── Slice.cs
├── DataTypes
│ ├── Annotation.cs
│ ├── CallbackArguments.cs
│ ├── CallbackFunction.cs
│ ├── Closure.cs
│ ├── Coroutine.cs
│ ├── CoroutineState.cs
│ ├── DataType.cs
│ ├── DynValue.cs
│ ├── IScriptPrivateResource.cs
│ ├── MemberModifierFlags.cs
│ ├── PreprocessorDefine.cs
│ ├── PreprocessorDefineType.cs
│ ├── Range.cs
│ ├── RefIdObject.cs
│ ├── ScriptFunctionDelegate.cs
│ ├── SymbolRef.cs
│ ├── SymbolRefType.cs
│ ├── Table.cs
│ ├── TableKind.cs
│ ├── TablePair.cs
│ ├── TailCallData.cs
│ ├── TypeValidationFlags.cs
│ ├── UserData.cs
│ ├── WattleMemberInfo.cs
│ ├── WattleMemberType.cs
│ ├── WattleMembersInfo.cs
│ ├── WellKnownSymbols.cs
│ └── YieldRequest.cs
├── Debugging
│ ├── DebugService.cs
│ ├── DebuggerAction.cs
│ ├── DebuggerCaps.cs
│ ├── IDebugger.cs
│ ├── SourceCode.cs
│ ├── SourceRef.cs
│ ├── WatchItem.cs
│ └── WatchType.cs
├── Diagnostics
│ ├── PerformanceCounter.cs
│ ├── PerformanceCounterType.cs
│ ├── PerformanceCounters
│ │ ├── DummyPerformanceStopwatch.cs
│ │ ├── GlobalPerformanceStopwatch.cs
│ │ ├── IPerformanceStopwatch.cs
│ │ └── PerformanceStopwatch.cs
│ ├── PerformanceResult.cs
│ └── PerformanceStatistics.cs
├── Errors
│ ├── DynamicExpressionException.cs
│ ├── InternalErrorException.cs
│ ├── InterpreterException.cs
│ ├── ScriptRuntimeException.cs
│ └── SyntaxErrorException.cs
├── Execution
│ ├── DynamicExpression.cs
│ ├── InstructionFieldUsage.cs
│ ├── Scopes
│ │ ├── BuildTimeScope.cs
│ │ ├── BuildTimeScopeBlock.cs
│ │ ├── BuildTimeScopeFrame.cs
│ │ ├── ClosureContext.cs
│ │ ├── IClosureBuilder.cs
│ │ ├── LoopTracker.cs
│ │ ├── RuntimeScopeBlock.cs
│ │ ├── RuntimeScopeFrame.cs
│ │ └── Upvalue.cs
│ ├── ScriptExecutionContext.cs
│ ├── ScriptLoadingContext.cs
│ └── VM
│ │ ├── CallStackItem.cs
│ │ ├── CallStackItemFlags.cs
│ │ ├── ExecutionState.cs
│ │ ├── FunctionBuilder.cs
│ │ ├── FunctionProto.cs
│ │ ├── Instruction.cs
│ │ ├── OpCode.cs
│ │ └── Processor
│ │ ├── DebugContext.cs
│ │ ├── Processor.cs
│ │ ├── Processor_BinaryDump.cs
│ │ ├── Processor_Coroutines.cs
│ │ ├── Processor_Debugger.cs
│ │ ├── Processor_Errors.cs
│ │ ├── Processor_IExecutionContext.cs
│ │ ├── Processor_InstructionLoop.cs
│ │ ├── Processor_Scope.cs
│ │ └── Processor_UtilityFunctions.cs
├── Extensions.cs
├── IAnnotationPolicy.cs
├── IO
│ ├── BinDumpReader.cs
│ └── BinDumpWriter.cs
├── Interop
│ ├── Attributes
│ │ ├── WattleScriptHiddenAttribute.cs
│ │ ├── WattleScriptHideMemberAttribute.cs
│ │ ├── WattleScriptPropertyAttribute.cs
│ │ ├── WattleScriptUserDataAttribute.cs
│ │ ├── WattleScriptUserDataMetamethodAttribute.cs
│ │ └── WattleScriptVisibleAttribute.cs
│ ├── BasicDescriptors
│ │ ├── DispatchingUserDataDescriptor.cs
│ │ ├── IMemberDescriptor.cs
│ │ ├── IOptimizableDescriptor.cs
│ │ ├── IOverloadableMemberDescriptor.cs
│ │ ├── MemberDescriptorAccess.cs
│ │ └── ParameterDescriptor.cs
│ ├── Converters
│ │ ├── ClrToScriptConversions.cs
│ │ ├── NumericConversions.cs
│ │ ├── ScriptToClrConversions.cs
│ │ ├── StringConversions.cs
│ │ └── TableConversions.cs
│ ├── CustomConvertersCollection.cs
│ ├── DescriptorHelpers.cs
│ ├── IGeneratorUserDataDescriptor.cs
│ ├── IUserDataDescriptor.cs
│ ├── IUserDataMemberDescriptor.cs
│ ├── IUserDataType.cs
│ ├── IWireableDescriptor.cs
│ ├── InteropAccessMode.cs
│ ├── InteropRegistrationPolicy.cs
│ ├── PredefinedUserData
│ │ ├── AnonWrapper.cs
│ │ ├── EnumerableWrapper.cs
│ │ └── TaskWrapper.cs
│ ├── PropertyTableAssigner.cs
│ ├── ProxyObjects
│ │ ├── DelegateProxyFactory.cs
│ │ └── IProxyFactory.cs
│ ├── ReflectionExtensions.cs
│ ├── ReflectionSpecialNames.cs
│ ├── RegistrationPolicies
│ │ ├── AutomaticRegistrationPolicy.cs
│ │ ├── DefaultRegistrationPolicy.cs
│ │ ├── IRegistrationPolicy.cs
│ │ └── PermanentRegistrationPolicy.cs
│ ├── StandardDescriptors
│ │ ├── AutoDescribingUserDataDescriptor.cs
│ │ ├── CompositeUserDataDescriptor.cs
│ │ ├── EventFacade.cs
│ │ ├── HardwiredDescriptors
│ │ │ ├── DefaultValue.cs
│ │ │ ├── HardwiredMemberDescriptor.cs
│ │ │ ├── HardwiredMethodMemberDescriptor.cs
│ │ │ └── HardwiredUserDataDescriptor.cs
│ │ ├── MemberDescriptors
│ │ │ ├── ArrayMemberDescriptor.cs
│ │ │ ├── DynValueMemberDescriptor.cs
│ │ │ ├── FunctionMemberDescriptorBase.cs
│ │ │ └── ObjectCallbackMemberDescriptor.cs
│ │ ├── ProxyUserDataDescriptor.cs
│ │ ├── ReflectionMemberDescriptors
│ │ │ ├── EventMemberDescriptor.cs
│ │ │ ├── FieldMemberDescriptor.cs
│ │ │ ├── MethodMemberDescriptor.cs
│ │ │ ├── OverloadedMethodMemberDescriptor.cs
│ │ │ ├── PropertyMemberDescriptor.cs
│ │ │ └── ValueTypeDefaultCtorMemberDescriptor.cs
│ │ ├── StandardEnumUserDataDescriptor.cs
│ │ ├── StandardGenericsUserDataDescriptor.cs
│ │ └── StandardUserDataDescriptor.cs
│ ├── UserDataMemberType.cs
│ └── UserDataRegistries
│ │ ├── ExtensionMethodsRegistry.cs
│ │ └── TypeDescriptorRegistry.cs
├── LinqHelpers.cs
├── Loaders
│ ├── EmbeddedResourcesScriptLoader.cs
│ ├── FileSystemScriptLoader.cs
│ ├── IScriptLoader.cs
│ ├── InvalidScriptLoader.cs
│ ├── ScriptLoaderBase.cs
│ └── UnityAssetsScriptLoader.cs
├── Modules
│ ├── CoreModules.cs
│ ├── ModuleRegister.cs
│ ├── WattleScriptModuleAttribute.cs
│ ├── WattleScriptModuleConstantAttribute.cs
│ └── WattleScriptModuleMethodAttribute.cs
├── NameSpace_XmlHelp.cs
├── Options
│ ├── ColonOperatorBehaviour.cs
│ ├── FuzzySymbolMatchingBehavior.cs
│ └── ScriptSyntax.cs
├── Platforms
│ ├── IPlatformAccessor.cs
│ ├── LimitedPlatformAccessor.cs
│ ├── PlatformAccessorBase.cs
│ ├── PlatformAutoDetector.cs
│ ├── StandardFileType.cs
│ └── StandardPlatformAccessor.cs
├── REPL
│ ├── ReplHistoryNavigator.cs
│ ├── ReplInterpreter.cs
│ └── ReplInterpreterScriptLoader.cs
├── Script.cs
├── ScriptGlobalOptions.cs
├── ScriptOptions.cs
├── Serialization
│ ├── Json
│ │ ├── JsonNull.cs
│ │ └── JsonTableConverter.cs
│ ├── ObjectValueConverter.cs
│ └── SerializationExtensions.cs
├── Tree
│ ├── Expression_.cs
│ ├── Expressions
│ │ ├── AdjustmentExpression.cs
│ │ ├── BinaryOperatorExpression.cs
│ │ ├── DynamicExprExpression.cs
│ │ ├── ExprListExpression.cs
│ │ ├── FunctionCallExpression.cs
│ │ ├── FunctionDefinitionExpression.cs
│ │ ├── IndexExpression.cs
│ │ ├── LiteralExpression.cs
│ │ ├── NewExpression.cs
│ │ ├── SymbolRefExpression.cs
│ │ ├── TableConstructor.cs
│ │ ├── TemplatedStringExpression.cs
│ │ ├── TernaryExpression.cs
│ │ └── UnaryOperatorExpression.cs
│ ├── Fast_Interface
│ │ └── Loader_Fast.cs
│ ├── GeneratedClosure.cs
│ ├── IVariable.cs
│ ├── Lexer
│ │ ├── Lexer.cs
│ │ ├── LexerUtils.cs
│ │ ├── Token.cs
│ │ └── TokenType.cs
│ ├── Loop.cs
│ ├── MemberCollection.cs
│ ├── MemberUtilities.cs
│ ├── NodeBase.cs
│ ├── Preprocessor
│ │ ├── DefineNode.cs
│ │ ├── DirectiveLexer.cs
│ │ ├── Preprocessor.cs
│ │ └── PreprocessorExpression.cs
│ ├── Statement.cs
│ ├── Statements
│ │ ├── AssignmentStatement.cs
│ │ ├── BreakStatement.cs
│ │ ├── CStyleForStatement.cs
│ │ ├── ChunkStatement.cs
│ │ ├── ClassDefinitionStatement.cs
│ │ ├── CompositeStatement.cs
│ │ ├── ContinueStatement.cs
│ │ ├── DoBlockStatement.cs
│ │ ├── EmptyStatement.cs
│ │ ├── EnumDefinitionStatement.cs
│ │ ├── ForEachLoopStatement.cs
│ │ ├── ForLoopStatement.cs
│ │ ├── FunctionCallStatement.cs
│ │ ├── FunctionDefinitionStatement.cs
│ │ ├── GotoStatement.cs
│ │ ├── IBlockStatement.cs
│ │ ├── IfStatement.cs
│ │ ├── LabelStatement.cs
│ │ ├── MixinDefinitionStatement.cs
│ │ ├── NewCallStatement.cs
│ │ ├── RepeatStatement.cs
│ │ ├── ReturnStatement.cs
│ │ ├── ScopeStatement.cs
│ │ ├── SwitchStatement.cs
│ │ └── WhileStatement.cs
│ └── TextCursor.cs
└── WattleScript.Interpreter.csproj
├── WattleScript.sln
└── WattleScript
├── Commands
├── CommandManager.cs
├── ICommand.cs
└── Implementations
│ ├── CompileCommand.cs
│ ├── DumpBytecodeCommand.cs
│ ├── ExitCommand.cs
│ ├── HardWireCommand.cs
│ ├── HelpCommand.cs
│ ├── RegisterCommand.cs
│ └── RunCommand.cs
├── Mono.Options.cs
├── Program.cs
├── WattleScript.csproj
└── wattlescript.ico
/.github/workflows/dotnet.yml:
--------------------------------------------------------------------------------
1 | name: .NET
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | pull_request:
7 | branches: [ main ]
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - uses: actions/checkout@v3
16 | - name: Setup .NET
17 | uses: actions/setup-dotnet@v2
18 | with:
19 | dotnet-version: |
20 | 6.0.x
21 | 8.0.x
22 | - name: Restore dependencies
23 | working-directory: ./src
24 | run: dotnet restore
25 | - name: Build
26 | working-directory: ./src
27 | run: dotnet build --no-restore
28 | - name: Test
29 | working-directory: ./src
30 | run: dotnet test --no-build --verbosity normal
31 |
--------------------------------------------------------------------------------
/AUTHORS:
--------------------------------------------------------------------------------
1 |
2 | # This is the list of WattleScript's significant contributors.
3 | #
4 | # This does not necessarily list everyone who has contributed code,
5 | # especially since many employees of one corporation may be contributing.
6 | # To see the full list of contributors, see the revision history in
7 | # source control.
8 |
9 | Marco Mastropaolo
10 | wledfor2
11 | NullShock78
12 | doritsugita
13 | Pedro Fanha
14 | Benjamin Dobell
15 | Kevin Morgan
16 | Callum McGing
17 | Matěj Štágl
18 |
--------------------------------------------------------------------------------
/src/README.md:
--------------------------------------------------------------------------------
1 | | File/Dir | Contents |
2 | | -------- | -------- |
3 | | WattleScript.Interpreter | The core project - the interpreter engine is here. |
4 | | WattleScript.Interpreter.Tests | Test suite, mostly end to end tests of various kinds |
5 | | WattleScript | Sources for the REPL interpreter |
6 | | WattleScriptTests | Tests runner to run the tests suite outside of Visual Studio (mainly, to test in Mono). |
7 | | WattleScript.sln | The solution containing everything |
8 | | README.md | This file |
9 |
10 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/Chapters/Chapter1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using WattleScript.Interpreter;
7 |
8 | namespace Tutorials.Chapters
9 | {
10 | [Tutorial]
11 | static class Chapter01
12 | {
13 | [Tutorial]
14 | public static double WattleScriptFactorial()
15 | {
16 | string script = @"
17 | -- defines a factorial function
18 | function fact (n)
19 | if (n == 0) then
20 | return 1
21 | else
22 | return n*fact(n - 1)
23 | end
24 | end
25 |
26 | return fact(5)";
27 |
28 | DynValue res = Script.RunString(script);
29 | return res.Number;
30 | }
31 |
32 |
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/Chapters/Chapter10.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using WattleScript.Interpreter;
8 | using WattleScript.Interpreter.Loaders;
9 | using WattleScript.Interpreter.Platforms;
10 |
11 | namespace Tutorials.Chapters
12 | {
13 | [Tutorial]
14 | static class Chapter10
15 | {
16 | [Tutorial]
17 | static void OverriddenPrint()
18 | {
19 | // redefine print to print in lowercase, for all new scripts
20 | Script.DefaultOptions.DebugPrint = s => Console.WriteLine(s.ToLower());
21 |
22 | Script script = new Script();
23 |
24 | DynValue fn = script.LoadString("print 'Hello, World!'");
25 |
26 | fn.Function.Call(); // this prints "hello, world!"
27 |
28 | // redefine print to print in UPPERCASE, for this script only
29 | script.Options.DebugPrint = s => Console.WriteLine(s.ToUpper());
30 |
31 | fn.Function.Call(); // this prints "HELLO, WORLD!"
32 | }
33 |
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/Chapters/Chapter2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using WattleScript.Interpreter;
7 |
8 | namespace Tutorials.Chapters
9 | {
10 | [Tutorial]
11 | static class Chapter02
12 | {
13 | public static double WattleScriptFactorial()
14 | {
15 | string scriptCode = @"
16 | -- defines a factorial function
17 | function fact (n)
18 | if (n == 0) then
19 | return 1
20 | else
21 | return n*fact(n - 1)
22 | end
23 | end
24 |
25 | return fact(mynumber)";
26 |
27 | Script script = new Script();
28 |
29 | script.Globals["mynumber"] = 7;
30 |
31 | DynValue res = script.DoString(scriptCode);
32 | return res.Number;
33 | }
34 |
35 |
36 |
37 | [Tutorial]
38 | public static double WattleScriptFactorial2()
39 | {
40 | string scriptCode = @"
41 | -- defines a factorial function
42 | function fact (n)
43 | if (n == 0) then
44 | return 1
45 | else
46 | return n*fact(n - 1)
47 | end
48 | end";
49 |
50 | Script script = new Script();
51 |
52 | script.DoString(scriptCode);
53 |
54 | DynValue res = script.Call(script.Globals["fact"], 4);
55 |
56 | return res.Number;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/Chapters/Chapter3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using WattleScript.Interpreter;
7 |
8 | namespace Tutorials.Chapters
9 | {
10 | [Tutorial]
11 | static class Chapter03
12 | {
13 | [Tutorial]
14 | public static double WattleScriptFactorial()
15 | {
16 | string scriptCode = @"
17 | -- defines a factorial function
18 | function fact (n)
19 | if (n == 0) then
20 | return 1
21 | else
22 | return n*fact(n - 1)
23 | end
24 | end";
25 |
26 | Script script = new Script();
27 |
28 | script.DoString(scriptCode);
29 |
30 | DynValue luaFactFunction = script.Globals.Get("fact");
31 |
32 | DynValue res = script.Call(luaFactFunction, 4);
33 |
34 | return res.Number;
35 | }
36 |
37 | [Tutorial]
38 | public static double WattleScriptFactorial2()
39 | {
40 | string scriptCode = @"
41 | -- defines a factorial function
42 | function fact (n)
43 | if (n == 0) then
44 | return 1
45 | else
46 | return n*fact(n - 1)
47 | end
48 | end";
49 |
50 | Script script = new Script();
51 |
52 | script.DoString(scriptCode);
53 |
54 | DynValue luaFactFunction = script.Globals.Get("fact");
55 |
56 | DynValue res = script.Call(luaFactFunction, DynValue.NewNumber(4));
57 |
58 | return res.Number;
59 | }
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/Chapters/Chapter5.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using WattleScript.Interpreter;
7 |
8 | namespace Tutorials.Chapters
9 | {
10 | [Tutorial]
11 | static class Chapter05
12 | {
13 | static StringBuilder GetString()
14 | {
15 | return new StringBuilder("myString!");
16 | }
17 |
18 | [Tutorial]
19 | public static void StringBuilderCustomConverter()
20 | {
21 | Script script = new Script();
22 |
23 | script.Globals["getstr"] = (Func)GetString;
24 |
25 | DynValue fn = script.LoadString("print(getstr())");
26 |
27 | fn.Function.Call();
28 |
29 | Script.GlobalOptions.CustomConverters.SetClrToScriptCustomConversion(
30 | v => DynValue.NewString(v.ToString().ToUpper()));
31 |
32 | fn.Function.Call();
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/Chapters/Chapter7.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using WattleScript.Interpreter;
7 |
8 | namespace Tutorials.Chapters
9 | {
10 | [Tutorial]
11 | static class Chapter07
12 | {
13 | [Tutorial]
14 | static void ErrorHandling()
15 | {
16 | try
17 | {
18 | string scriptCode = @"
19 | return obj.calcHypotenuse(3, 4);
20 | ";
21 |
22 | Script script = new Script();
23 | DynValue res = script.DoString(scriptCode);
24 | }
25 | catch (ScriptRuntimeException ex)
26 | {
27 | Console.WriteLine("Doh! An error occured! {0}", ex.DecoratedMessage);
28 | }
29 | }
30 |
31 | static void DoError()
32 | {
33 | throw new ScriptRuntimeException("This is an exceptional message, no pun intended.");
34 | }
35 |
36 | [Tutorial]
37 | static string ErrorGen()
38 | {
39 | string scriptCode = @"
40 | local _, msg = pcall(DoError);
41 | return msg;
42 | ";
43 |
44 | Script script = new Script();
45 | script.Globals["DoError"] = (Action)DoError;
46 | DynValue res = script.DoString(scriptCode);
47 | return res.String;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/Chapters/Chapter8.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using WattleScript.Interpreter;
8 | using WattleScript.Interpreter.Loaders;
9 |
10 | namespace Tutorials.Chapters
11 | {
12 | [Tutorial]
13 | static class Chapter08
14 | {
15 | [Tutorial]
16 | static void EmbeddedResourceScriptLoader()
17 | {
18 | Script script = new Script();
19 | script.Options.ScriptLoader = new EmbeddedResourcesScriptLoader(Assembly.GetExecutingAssembly());
20 | script.DoFile("Scripts/Test.lua");
21 | }
22 |
23 | private class MyCustomScriptLoader : ScriptLoaderBase
24 | {
25 | public override object LoadFile(string file, Table globalContext)
26 | {
27 | return string.Format("print ([[A request to load '{0}' has been made]])", file);
28 | }
29 |
30 | public override bool ScriptFileExists(string name)
31 | {
32 | return true;
33 | }
34 | }
35 |
36 | [Tutorial]
37 | static void CustomScriptLoader()
38 | {
39 | Script script = new Script();
40 |
41 | script.Options.ScriptLoader = new MyCustomScriptLoader()
42 | {
43 | ModulePaths = new string[] { "?_module.lua" }
44 | };
45 |
46 | script.DoString(@"
47 | require 'somemodule'
48 | f = loadfile 'someothermodule.lua'
49 | f()
50 | ");
51 | }
52 |
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/Chapters/Chapter9.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using WattleScript.Interpreter;
8 | using WattleScript.Interpreter.Loaders;
9 | using WattleScript.Interpreter.Platforms;
10 |
11 | namespace Tutorials.Chapters
12 | {
13 | [Tutorial]
14 | static class Chapter09
15 | {
16 | [Tutorial]
17 | static void ChangePlatform()
18 | {
19 | // This prints "function"
20 | Console.WriteLine(Script.RunString("return type(os.exit);").ToPrintString());
21 |
22 | // Save the old platform
23 | var oldplatform = Script.GlobalOptions.Platform;
24 |
25 | // Changing platform after a script has been created is not recommended.. do not do it.
26 | // We are doing it for the purpose of the walkthrough..
27 | Script.GlobalOptions.Platform = new LimitedPlatformAccessor();
28 |
29 | // This time, this prints "nil"
30 | Console.WriteLine(Script.RunString("return type(os.exit);").ToPrintString());
31 |
32 | // Restore the old platform
33 | Script.GlobalOptions.Platform = oldplatform;
34 | }
35 |
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/Scripts/Test.lua:
--------------------------------------------------------------------------------
1 | -- Sample script embedded as a resource.
2 |
3 | for i = 1, 5 do
4 | print "Hello world!"
5 | end
6 |
7 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/TutorialAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Tutorials
8 | {
9 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
10 | public sealed class TutorialAttribute : Attribute
11 | {
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Tutorial/Tutorials/readme.md:
--------------------------------------------------------------------------------
1 | WattleScript Tutorials
2 | ===================
3 |
4 |
5 | These are sources for the tutorials contained at http://www.moonsharp.org/getting_started.html and following pages.
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/Generators/FieldMemberDescriptorGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using WattleScript.Interpreter;
7 | using WattleScript.Interpreter.Interop;
8 | using WattleScript.Interpreter.Interop.BasicDescriptors;
9 | using WattleScript.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors;
10 |
11 | namespace WattleScript.Hardwire.Generators
12 | {
13 | class FieldMemberDescriptorGenerator : AssignableMemberDescriptorGeneratorBase
14 | {
15 | public override string ManagedType
16 | {
17 | get { return "WattleScript.Interpreter.Interop.FieldMemberDescriptor"; }
18 | }
19 |
20 | protected override CodeExpression GetMemberAccessExpression(CodeExpression thisObj, string name)
21 | {
22 | return new CodeFieldReferenceExpression(thisObj, name);
23 | }
24 |
25 | protected override string GetPrefix()
26 | {
27 | return "FLDV";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/Generators/NullGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using WattleScript.Interpreter;
7 |
8 | namespace WattleScript.Hardwire.Generators
9 | {
10 | internal class NullGenerator : IHardwireGenerator
11 | {
12 | public NullGenerator()
13 | {
14 | ManagedType = "";
15 | }
16 |
17 | public NullGenerator(string type)
18 | {
19 | ManagedType = type;
20 | }
21 |
22 | public string ManagedType
23 | {
24 | get;
25 | private set;
26 | }
27 |
28 | public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members)
29 | {
30 | generator.Error("Missing code generator for '{0}'.", ManagedType);
31 |
32 | return new CodeExpression[0];
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/Generators/OverloadedMethodMemberDescriptorGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using WattleScript.Interpreter;
7 | using WattleScript.Interpreter.Interop;
8 | using WattleScript.Interpreter.Interop.BasicDescriptors;
9 |
10 | namespace WattleScript.Hardwire.Generators
11 | {
12 | class OverloadedMethodMemberDescriptorGenerator : IHardwireGenerator
13 | {
14 | public string ManagedType
15 | {
16 | get { return "WattleScript.Interpreter.Interop.OverloadedMethodMemberDescriptor"; }
17 | }
18 |
19 | public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generator,
20 | CodeTypeMemberCollection members)
21 | {
22 | List initializers = new List();
23 |
24 | generator.DispatchTablePairs(parent + (table["name"] as string), table.Get("overloads").Table, members, exp =>
25 | {
26 | initializers.Add(exp);
27 | });
28 |
29 | var name = new CodePrimitiveExpression((table["name"] as string));
30 | var type = new CodeTypeOfExpression(table["decltype"] as string);
31 |
32 | var array = new CodeArrayCreateExpression(typeof(IOverloadableMemberDescriptor), initializers.ToArray());
33 |
34 | return new CodeExpression[] {
35 | new CodeObjectCreateExpression(typeof(OverloadedMethodMemberDescriptor), name, type, array)
36 | };
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/Generators/PropertyMemberDescriptorGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using WattleScript.Interpreter;
7 | using WattleScript.Interpreter.Interop;
8 | using WattleScript.Interpreter.Interop.BasicDescriptors;
9 | using WattleScript.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors;
10 |
11 | namespace WattleScript.Hardwire.Generators
12 | {
13 | class PropertyMemberDescriptorGenerator : AssignableMemberDescriptorGeneratorBase
14 | {
15 | public override string ManagedType
16 | {
17 | get { return "WattleScript.Interpreter.Interop.PropertyMemberDescriptor"; }
18 | }
19 |
20 | protected override CodeExpression GetMemberAccessExpression(CodeExpression thisObj, string name)
21 | {
22 | return new CodePropertyReferenceExpression(thisObj, name);
23 | }
24 |
25 | protected override string GetPrefix()
26 | {
27 | return "PROP";
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/Generators/ValueTypeDefaultCtorMemberDescriptorGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using WattleScript.Interpreter;
7 | using WattleScript.Interpreter.Interop.BasicDescriptors;
8 | using WattleScript.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors;
9 |
10 | namespace WattleScript.Hardwire.Generators
11 | {
12 | class ValueTypeDefaultCtorMemberDescriptorGenerator : IHardwireGenerator
13 | {
14 | public string ManagedType
15 | {
16 | get { return "WattleScript.Interpreter.Interop.ValueTypeDefaultCtorMemberDescriptor"; }
17 | }
18 |
19 | public CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generator, CodeTypeMemberCollection members)
20 | {
21 | MethodMemberDescriptorGenerator mgen = new MethodMemberDescriptorGenerator("VTDC");
22 |
23 | Table mt = new Table(null);
24 |
25 | mt["params"] = new Table(null);
26 | mt["name"] = "__new";
27 | mt["type"] = table["type"];
28 | mt["ctor"] = true;
29 | mt["extension"] = false;
30 | mt["decltype"] = table["type"];
31 | mt["ret"] = table["type"];
32 | mt["special"] = false;
33 |
34 |
35 | return mgen.Generate(parent, mt, generator, members);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/HardwireGeneratorRegistry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using WattleScript.Hardwire.Generators;
7 | using WattleScript.Interpreter;
8 |
9 | namespace WattleScript.Hardwire
10 | {
11 | public static class HardwireGeneratorRegistry
12 | {
13 | static Dictionary m_Generators = new Dictionary();
14 |
15 | public static void Register(IHardwireGenerator g)
16 | {
17 | m_Generators[g.ManagedType] = g;
18 | }
19 |
20 | public static IHardwireGenerator GetGenerator(string type)
21 | {
22 | if (m_Generators.ContainsKey(type))
23 | return m_Generators[type];
24 | else
25 | return new NullGenerator(type);
26 | }
27 |
28 | public static void RegisterPredefined()
29 | {
30 | DiscoverFromAssembly(Assembly.GetExecutingAssembly());
31 | }
32 |
33 |
34 | public static void DiscoverFromAssembly(Assembly asm = null)
35 | {
36 | if (asm == null)
37 | asm = Assembly.GetCallingAssembly();
38 |
39 | foreach (Type type in asm.GetTypes()
40 | .Where(t => !(t.IsAbstract || t.IsGenericTypeDefinition || t.IsGenericType))
41 | .Where(t => (typeof(IHardwireGenerator)).IsAssignableFrom(t)))
42 | {
43 | IHardwireGenerator g = (IHardwireGenerator)Activator.CreateInstance(type);
44 | Register(g);
45 | }
46 | }
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/ICodeGenerationLogger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WattleScript.Hardwire
7 | {
8 | public interface ICodeGenerationLogger
9 | {
10 | void LogError(string message);
11 | void LogWarning(string message);
12 | void LogMinor(string message);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/IHardwireGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using WattleScript.Interpreter;
6 |
7 | namespace WattleScript.Hardwire
8 | {
9 | ///
10 | /// Interface to be implemented by all hardwire code generators
11 | ///
12 | public interface IHardwireGenerator
13 | {
14 | ///
15 | /// Gets the type which is managed by this generator. Should be an exact match with the 'class' entry in the
16 | /// codegen table.
17 | ///
18 | string ManagedType { get; }
19 |
20 | ///
21 | /// Generates code from a dump of the type.
22 | ///
23 | /// The table containing the data to be parsed.
24 | /// The generator context.
25 | /// The CodeTypeMemberCollection which can be used to add newly defined types.
26 | /// Zero or more expressions which can be used by the parent generator to use the generated code.
27 | CodeExpression[] Generate(string parent, Table table, HardwireCodeGenerationContext generatorContext, CodeTypeMemberCollection members);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/Utils/GeneratorUtilities.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using WattleScript.Interpreter;
7 | using WattleScript.Interpreter.Interop.BasicDescriptors;
8 | using WattleScript.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors;
9 |
10 | namespace WattleScript.Hardwire.Utils
11 | {
12 | public class GeneratorUtilities
13 | {
14 |
15 |
16 |
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/WattleScript.Hardwire/WattleScript.Hardwire.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/WattleScript.HardwireGen.Test/ExtraHardwire.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ]]>
4 |
--------------------------------------------------------------------------------
/src/WattleScript.HardwireGen.Test/GenericExtra.cs:
--------------------------------------------------------------------------------
1 | namespace WattleScript.HardwireGen.Test;
2 |
3 | public class GenericExtra
4 | {
5 | public T? Value;
6 |
7 | public int DoThing()
8 | {
9 | return 1234;
10 | }
11 | }
--------------------------------------------------------------------------------
/src/WattleScript.HardwireGen.Test/MyWattleData.cs:
--------------------------------------------------------------------------------
1 | using WattleScript.Interpreter;
2 |
3 | namespace WattleScript.HardwireGen.Test;
4 |
5 | [WattleScriptUserData]
6 | public class MyWattleData
7 | {
8 | public string Value = "";
9 |
10 | public int Add4(int a)
11 | {
12 | return a + 4;
13 | }
14 |
15 | public MyWattleData()
16 | {
17 | }
18 |
19 | public MyWattleData(string value)
20 | {
21 | Value = value;
22 | }
23 | }
--------------------------------------------------------------------------------
/src/WattleScript.HardwireGen.Test/WattleScript.HardwireGen.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | enable
6 |
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/WattleScript.HardwireGen.Test/WithProperty.cs:
--------------------------------------------------------------------------------
1 | using WattleScript.Interpreter;
2 |
3 | namespace WattleScript.HardwireGen.Test;
4 |
5 | [WattleScriptUserData]
6 | public class WithProperty
7 | {
8 | public int Property { get; set; }
9 | }
--------------------------------------------------------------------------------
/src/WattleScript.HardwireGen/ClassNames.cs:
--------------------------------------------------------------------------------
1 | namespace WattleScript.HardwireGen
2 | {
3 | public static class ClassNames
4 | {
5 | public const string CLS_USERDATA =
6 | "WattleScript.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredUserDataDescriptor";
7 |
8 | public const string CLS_OVERLOAD = "WattleScript.Interpreter.Interop.OverloadedMethodMemberDescriptor";
9 |
10 | public const string CLS_OVERLOAD_MEMBER =
11 | "WattleScript.Interpreter.Interop.BasicDescriptors.IOverloadableMemberDescriptor";
12 |
13 | public const string CLS_PROP_FIELD =
14 | "WattleScript.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMemberDescriptor";
15 |
16 | public const string CLS_METHOD =
17 | "WattleScript.Interpreter.Interop.StandardDescriptors.HardwiredDescriptors.HardwiredMethodMemberDescriptor";
18 |
19 | public const string CLS_PARAMETER = "WattleScript.Interpreter.Interop.BasicDescriptors.ParameterDescriptor";
20 |
21 |
22 | }
23 | }
--------------------------------------------------------------------------------
/src/WattleScript.HardwireGen/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/launchsettings.json",
3 | "profiles": {
4 | "Generators": {
5 | "commandName": "DebugRoslynComponent",
6 | "targetProject": "../WattleScript.HardwireGen.Test/WattleScript.HardwireGen.Test.csproj"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/WattleScript.HardwireGen/StringUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.CodeAnalysis.CSharp;
3 |
4 | namespace WattleScript.HardwireGen
5 | {
6 | public static class StringUtils
7 | {
8 | public static string ToLiteral(this string input)
9 | {
10 | return SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(input)).ToFullString();
11 | }
12 |
13 | }
14 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/01-private-field.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | private x = 7;
4 | }
5 |
6 | print(new A().x)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/01-private-field.txt:
--------------------------------------------------------------------------------
1 | nil
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/02-private-nowrite-invalid.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | private x = 7;
4 | }
5 |
6 | var i = new A();
7 | i.x = 3;
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/03-private-thisaccess.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | private x = 7;
4 | printx()
5 | {
6 | print(this.x);
7 | }
8 | }
9 |
10 | new A().printx();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/03-private-thisaccess.txt:
--------------------------------------------------------------------------------
1 | 7
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/04-private-base.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | private x = 7;
4 | }
5 |
6 | class B : A
7 | {
8 | printx()
9 | {
10 | print(this.x);
11 | }
12 | }
13 |
14 | var i = new B();
15 | print(i.x);
16 | i.printx();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/04-private-base.txt:
--------------------------------------------------------------------------------
1 | nil
2 | 7
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/05-private-mixin.lua:
--------------------------------------------------------------------------------
1 | mixin A
2 | {
3 | private x = 7;
4 | }
5 |
6 | class B with A
7 | {
8 | printx()
9 | {
10 | print(this.x);
11 | }
12 | }
13 |
14 | var i = new B();
15 | print(i.x);
16 | i.printx();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/05-private-mixin.txt:
--------------------------------------------------------------------------------
1 | nil
2 | 7
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/06-privatestatic-invalid.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | private static x = 7;
4 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/07-public.lua:
--------------------------------------------------------------------------------
1 | mixin B
2 | {
3 | public y = 9;
4 | }
5 | class A with B
6 | {
7 | public x = 8;
8 | }
9 |
10 | print(new A().x)
11 | print(new A().y)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/07-public.txt:
--------------------------------------------------------------------------------
1 | 8
2 | 9
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Access/08-conflicting-access-invalid.lua:
--------------------------------------------------------------------------------
1 | class X
2 | {
3 | public private Z = 9;
4 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Aliases/1-null.lua:
--------------------------------------------------------------------------------
1 | x = null
2 | print(x)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Aliases/1-null.txt:
--------------------------------------------------------------------------------
1 | nil
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Aliases/2-this.lua:
--------------------------------------------------------------------------------
1 | Account = {balance = 100}
2 | function Account:withdraw (v)
3 | this.balance = this.balance - v
4 | end
5 |
6 | Account::withdraw(60)
7 | print(Account.balance)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Aliases/2-this.txt:
--------------------------------------------------------------------------------
1 | 40
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/1-annotation.lua:
--------------------------------------------------------------------------------
1 | @bind("html-name", "cool")
2 | function f() {
3 |
4 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/1-annotation.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/1-annotation.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/2-annotation.lua:
--------------------------------------------------------------------------------
1 | @bind("html-name")
2 | function f() {
3 |
4 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/2-annotation.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/2-annotation.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/3-annotation.lua:
--------------------------------------------------------------------------------
1 | @bind
2 | function f() {
3 |
4 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/3-annotation.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/3-annotation.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/4-annotation.lua:
--------------------------------------------------------------------------------
1 | @bind("tbl1")
2 | @bind2({"tbl2", "tbl3"})
3 | @bind3("tbl4", "tbl6")
4 | function f() {
5 |
6 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/4-annotation.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/4-annotation.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/5-annotation.lua:
--------------------------------------------------------------------------------
1 | @bind2({"tbl2", "tbl3"})
2 | function f() {
3 |
4 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/5-annotation.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Annotations/5-annotation.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/0-new.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | A(value)
4 | {
5 | this.value = value;
6 | }
7 |
8 | printvalue() => print(this.value);
9 | }
10 |
11 | new A("hello").printvalue();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/0-new.txt:
--------------------------------------------------------------------------------
1 | hello
2 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/1-classloop.lua:
--------------------------------------------------------------------------------
1 | function errprint(code) {
2 | local status, err = pcall(code)
3 | print(err)
4 | }
5 |
6 | class A : B { }
7 | class B : A { printthing() => print("hello"); }
8 |
9 | errprint(() => { new B().printthing(); });
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/1-classloop.txt:
--------------------------------------------------------------------------------
1 | chunk_0:(7,6-11): class hierarchy contains cyclic reference (B)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/10-static-field-ref.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | static MyProp = "test"
4 | static MyProp2 = this.MyProp + "2"
5 | }
6 |
7 | print(A.MyProp2)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/10-static-field-ref.txt:
--------------------------------------------------------------------------------
1 | test2
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/11-duplicate-function-invalid.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | function f() {
4 |
5 | }
6 |
7 | function f() {
8 |
9 | }
10 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/11-duplicate-function-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/11-duplicate-function-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/12-duplicate-field-invalid.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | bar = 10
4 | bar = 20
5 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/12-duplicate-field-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/12-duplicate-field-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/13-reserved-field-invalid.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | static function __ctor() {
4 |
5 | }
6 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/13-reserved-field-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/13-reserved-field-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/14-static-math.lua:
--------------------------------------------------------------------------------
1 | static class Math {
2 | static PI = 3.1415926535
3 |
4 | static function Sum(a, b) {
5 | return a + b
6 | }
7 |
8 | static CircleArea = (r) => {
9 | return this.PI * r ** 2
10 | }
11 | }
12 |
13 | print(Math.Sum(5, 1))
14 | print(Math.CircleArea(10))
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/14-static-math.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 314.15926535
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/15-static-class-empty.lua:
--------------------------------------------------------------------------------
1 | static class Math {
2 |
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/15-static-class-empty.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/15-static-class-empty.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/16-static-class-empty-invalid.lua:
--------------------------------------------------------------------------------
1 | static static class Math {
2 |
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/17-static-class-non-static-field-invalid.lua:
--------------------------------------------------------------------------------
1 | static class Math {
2 | PI = 3.14
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/18-static-class-non-static-function-invalid.lua:
--------------------------------------------------------------------------------
1 | static class Math {
2 | function PI() {
3 | return 3.14
4 | }
5 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/19-static-class-non-static-function-arrow-invalid.lua:
--------------------------------------------------------------------------------
1 | static class Math {
2 | PI = () => {
3 | return 3.14
4 | }
5 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/2-mixin.lua:
--------------------------------------------------------------------------------
1 | mixin MixA {
2 | printvalue() => print(this.value);
3 | }
4 |
5 | class A with MixA {
6 | A(value) {
7 | this.value = value;
8 | }
9 | }
10 |
11 | new A("hello").printvalue();
12 |
13 | mixin MixB {
14 | printvalue() => print("not ok hello");
15 | }
16 |
17 | class B with MixB {
18 | B(value) {
19 | this.value = value;
20 | }
21 | printvalue() => print(this.value);
22 | }
23 |
24 | new B("hello").printvalue(); //class function defs override mixin defs
25 |
26 | mixin MixinValue {
27 | value = "hello!! :)"
28 | }
29 |
30 | class C with MixinValue, MixA { } //mixins also add data. multiple mixin usage
31 |
32 | new C().printvalue();
33 |
34 | //mixins cannot define constructors
35 | mixin M {
36 | M2(value) { this.value = value }
37 | }
38 |
39 | class M2 with M { }
40 |
41 | print(new M2("hello").value == nil);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/2-mixin.txt:
--------------------------------------------------------------------------------
1 | hello
2 | hello
3 | hello!! :)
4 | true
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/20-static-class-ctor-invalid.lua:
--------------------------------------------------------------------------------
1 | static class Math {
2 | Math() {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/21-static-class-ctor-static-invalid.lua:
--------------------------------------------------------------------------------
1 | static class Math {
2 | static Math() {
3 |
4 | }
5 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/22-class-lhs-new.lua:
--------------------------------------------------------------------------------
1 | class C {
2 | C() {
3 | print("ctor side effect")
4 | }
5 |
6 | f() {
7 | print("something")
8 | }
9 | }
10 |
11 | new C()
12 | new C().f()
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/22-class-lhs-new.txt:
--------------------------------------------------------------------------------
1 | ctor side effect
2 | ctor side effect
3 | something
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/23-static-class-instantiate-invalid.lua:
--------------------------------------------------------------------------------
1 | static class Math {
2 |
3 | }
4 |
5 | new Math()
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/24-static-class-base-invalid.lua:
--------------------------------------------------------------------------------
1 | class Math2 : Math {
2 |
3 | }
4 |
5 | static class Math {
6 |
7 | }
8 |
9 | new Math2()
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/25-static-class-static-field-function-ref.lua:
--------------------------------------------------------------------------------
1 | static class X {
2 | static function Y() { print(10) }
3 | static T = this.Y
4 | static function Z() { print(this.T()) }
5 | }
6 |
7 | X.Z()
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/25-static-class-static-field-function-ref.txt:
--------------------------------------------------------------------------------
1 | 10
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/26-class-field-thiscall.lua:
--------------------------------------------------------------------------------
1 | class A {
2 | Y = "hello"
3 | X = this.Y
4 | Z = 10
5 | X2 = this.X + this.Z
6 | }
7 |
8 | a = new A()
9 | print(a.X)
10 | print(a.X2)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/26-class-field-thiscall.txt:
--------------------------------------------------------------------------------
1 | hello
2 | hello10
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/27-class-field-thiscall-function.lua:
--------------------------------------------------------------------------------
1 | class A {
2 | Y = () => { print("hello") }
3 | }
4 |
5 | new A().Y()
6 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/27-class-field-thiscall-function.txt:
--------------------------------------------------------------------------------
1 | hello
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/28-class-sealed-invalid.lua:
--------------------------------------------------------------------------------
1 | class B : A {}
2 | sealed class A {}
3 |
4 | new B()
5 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/29-class-sealed.lua:
--------------------------------------------------------------------------------
1 | sealed class A {
2 | public a = 0
3 | }
4 | print(new A().a)
5 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/29-class-sealed.txt:
--------------------------------------------------------------------------------
1 | 0
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/3-basecall.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | printx() => print("x");
4 | }
5 |
6 | class B : A
7 | {
8 | printx2() => base.printx();
9 | }
10 |
11 | new B().printx2();
12 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/3-basecall.txt:
--------------------------------------------------------------------------------
1 | x
2 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/4-baseconstruct.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | A(value)
4 | {
5 | this.value = value;
6 | }
7 | }
8 |
9 | class B : A
10 | {
11 | B(value)
12 | {
13 | base(value);
14 | this.value2 = value;
15 | }
16 | }
17 |
18 | var x = new B("hello");
19 | print(x.value2 == x.value);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/4-baseconstruct.txt:
--------------------------------------------------------------------------------
1 | true
2 |
3 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/5-baseconstruct-default.lua:
--------------------------------------------------------------------------------
1 | // Testing that an empty __ctor is generated on base classes
2 | // That have ctor
3 |
4 | class A { }
5 | class B : A {
6 | B() { base() }
7 | printval() => print("yes");
8 | }
9 |
10 | new B().printval();
11 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/5-baseconstruct-default.txt:
--------------------------------------------------------------------------------
1 | yes
2 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/6-baseclass-invalid.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | }
4 |
5 | class B : A
6 | {
7 | dothing() => {
8 | base = 7; //Cannot write to base, compiler error.
9 | print("hello");
10 | }
11 | }
12 |
13 | new B().dothing();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/6-baseclass-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/6-baseclass-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/7-static.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | function f3() {
4 | return 8
5 | }
6 |
7 | static function f() {
8 | return 10
9 | }
10 |
11 | static function f2() {
12 | return 12
13 | }
14 | }
15 |
16 | function g() {
17 | return 6
18 | }
19 |
20 | print(A.f());
21 | print(A.f2());
22 | print(A.f());
23 | print(new A().f3());
24 | print(g())
25 | print(A.f());
26 | print(A.f2());
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/7-static.txt:
--------------------------------------------------------------------------------
1 | 10
2 | 12
3 | 10
4 | 8
5 | 6
6 | 10
7 | 12
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/8-static-local-ref.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | static bar = "bar"
4 |
5 | static function f1() {
6 | return 2
7 | }
8 |
9 | static function f2() {
10 | return this.f1() + 3 + this.bar
11 | }
12 | }
13 |
14 | print(A.f2())
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/8-static-local-ref.txt:
--------------------------------------------------------------------------------
1 | 5bar
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/9-static-field.lua:
--------------------------------------------------------------------------------
1 | class A
2 | {
3 | static MyProp = "test"
4 | static function F1() {
5 | return this.MyProp + "2"
6 | }
7 | }
8 |
9 | function F1() {
10 | return "error"
11 | }
12 |
13 | print(A.MyProp)
14 | print(A.F1())
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Classes/9-static-field.txt:
--------------------------------------------------------------------------------
1 | test
2 | test2
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Enums/0-enum.lua:
--------------------------------------------------------------------------------
1 | function errprint(code) {
2 | local status, err = pcall(code)
3 | print(err)
4 | }
5 |
6 | enum Colors {
7 | Red,
8 | Green,
9 | Blue,
10 | Orange = 4,
11 | Purple,
12 | Pink = 4,
13 | Grey,
14 | Aquamarine = (1 << 4),
15 | }
16 |
17 | print(Colors.Red)
18 | print(Colors.Green)
19 | print(Colors.Blue)
20 | print(Colors.Orange)
21 | print(Colors.Purple)
22 | print(Colors.Pink)
23 | print(Colors.Grey)
24 | print(Colors.Aquamarine)
25 |
26 | errprint(() => { Colors.Red = 2 })
27 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Enums/0-enum.txt:
--------------------------------------------------------------------------------
1 | 0
2 | 1
3 | 2
4 | 4
5 | 5
6 | 4
7 | 5
8 | 16
9 | chunk_0:(26,17-31): table is readonly
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Enums/1-selfref.lua:
--------------------------------------------------------------------------------
1 | enum Flags {
2 | A = (1 << 1),
3 | B = (1 << 2),
4 | AB = A | B
5 | }
6 |
7 | print(Flags.A);
8 | print(Flags.B);
9 | print(Flags.AB);
10 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Enums/1-selfref.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 4
3 | 6
4 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Enums/2-annotsyntax.lua:
--------------------------------------------------------------------------------
1 | // Just testing that compile succeeds
2 | @tbl ({ "hello", "world", x = 7})
3 | enum Hello {
4 | Val1,
5 | Val2,
6 | Val3
7 | }
8 | print("ok")
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Enums/2-annotsyntax.txt:
--------------------------------------------------------------------------------
1 | ok
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Errors/1-common-invalid.lua:
--------------------------------------------------------------------------------
1 | if (
2 |
3 | x = 0
4 | x1 = []
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Errors/1-common-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Errors/1-common-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Errors/2-resync-invalid.lua:
--------------------------------------------------------------------------------
1 | if (
2 |
3 | x = 0
4 | x1 = []
5 |
6 | local x1 = = =
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Errors/2-resync-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Errors/2-resync-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/1-call.lua:
--------------------------------------------------------------------------------
1 | function f1(a, b, c) {}
2 |
3 | f1(10, 20);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/1-call.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/1-call.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/10-call-default-scope-local-3.lua:
--------------------------------------------------------------------------------
1 | local function f1(a = 500) {
2 | print("a: " + a)
3 | }
4 |
5 | f1()
6 |
7 | if (2 > 1) {
8 |
9 | local function f1(a = 600) {
10 | print("a: " + a)
11 | }
12 |
13 | f1()
14 | }
15 |
16 | f1()
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/10-call-default-scope-local-3.txt:
--------------------------------------------------------------------------------
1 | a: 500
2 | a: 600
3 | a: 500
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/11-call-default-scope-arrow.lua:
--------------------------------------------------------------------------------
1 | f = (x = 500) => {
2 | print(x)
3 | }
4 |
5 | f();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/11-call-default-scope-arrow.txt:
--------------------------------------------------------------------------------
1 | 500
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/12-call-default-scope-arrow-invalid.lua:
--------------------------------------------------------------------------------
1 | f = (x = 500, x2) => {
2 | print(x)
3 | }
4 |
5 | f();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/12-call-default-scope-arrow-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/12-call-default-scope-arrow-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/13-call-default-scope-arrow-arrow.lua:
--------------------------------------------------------------------------------
1 | f = (x) => {
2 | x()
3 | }
4 |
5 | f(() => {
6 | print("yes")
7 | });
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/13-call-default-scope-arrow-arrow.txt:
--------------------------------------------------------------------------------
1 | yes
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/14-call-default-scope-arrow-arrow-default.lua:
--------------------------------------------------------------------------------
1 | f = (x = () => {print("yes")}) => {
2 | x()
3 | }
4 |
5 | f();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/14-call-default-scope-arrow-arrow-default.txt:
--------------------------------------------------------------------------------
1 | yes
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/15-call-default-scope-arrow-arrow-default-2.lua:
--------------------------------------------------------------------------------
1 | f = (x = () => {print("yes")}) => {
2 | x()
3 | }
4 |
5 | f(() => {
6 | print("no")
7 | });
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/15-call-default-scope-arrow-arrow-default-2.txt:
--------------------------------------------------------------------------------
1 | no
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/16-default-call-closure.lua:
--------------------------------------------------------------------------------
1 | local z = 2
2 |
3 | f = (x = () => {print(z)}) => {
4 | x()
5 | }
6 |
7 | z = 3
8 |
9 | f();
10 |
11 | function test2() {
12 | local z = 2
13 | f = (x = () => {print(z)}) => {
14 | x()
15 | }
16 | z = 7;
17 | return f;
18 | }
19 |
20 | local f2 = test2();
21 | f2();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/16-default-call-closure.txt:
--------------------------------------------------------------------------------
1 | 3
2 | 7
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/17-call-hoisted.lua:
--------------------------------------------------------------------------------
1 | f();
2 | //This will be hoisted to the top of the block.
3 | function f()
4 | {
5 | print("hello world!");
6 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/17-call-hoisted.txt:
--------------------------------------------------------------------------------
1 | hello world!
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/18-assign-lambda.lua:
--------------------------------------------------------------------------------
1 | function assign(value) => globalVar = value;
2 |
3 | assign("hello");
4 | print(globalVar);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/18-assign-lambda.txt:
--------------------------------------------------------------------------------
1 | hello
2 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/2-call-default.lua:
--------------------------------------------------------------------------------
1 | function f1(a, b, c = 100) {
2 | print("a: " + a)
3 | print("b: " + b)
4 | print("c: " + c)
5 | }
6 |
7 | f1(10, 20);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/2-call-default.txt:
--------------------------------------------------------------------------------
1 | a: 10
2 | b: 20
3 | c: 100
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/3-call-default-invalid.lua:
--------------------------------------------------------------------------------
1 | function f1(a = 50, b, c = 100) {
2 | print("a: " + a)
3 | print("b: " + b)
4 | print("c: " + c)
5 | }
6 |
7 | f1(10, 20);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/3-call-default-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/3-call-default-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/4-call-default-2.lua:
--------------------------------------------------------------------------------
1 | function f1(a = 80) {
2 | print("a: " + a)
3 | }
4 |
5 | f1(10);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/4-call-default-2.txt:
--------------------------------------------------------------------------------
1 | a: 10
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/5-call-default-3.lua:
--------------------------------------------------------------------------------
1 | function f1(a = 80) {
2 | print("a: " + a)
3 | }
4 |
5 | f1();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/5-call-default-3.txt:
--------------------------------------------------------------------------------
1 | a: 80
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/6-call-default-local.lua:
--------------------------------------------------------------------------------
1 | local function f1(a = 80) {
2 | print("a: " + a)
3 | }
4 |
5 | f1();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/6-call-default-local.txt:
--------------------------------------------------------------------------------
1 | a: 80
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/7-call-default-scope.lua:
--------------------------------------------------------------------------------
1 | function f1(a = 500) {
2 | print("global a: " + a)
3 | }
4 |
5 | if (2 > 1) {
6 | f1()
7 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/7-call-default-scope.txt:
--------------------------------------------------------------------------------
1 | global a: 500
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/8-call-default-scope-local.lua:
--------------------------------------------------------------------------------
1 | local function f1(a = 500) {
2 | print("a: " + a)
3 | }
4 |
5 | if (2 > 1) {
6 | f1()
7 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/8-call-default-scope-local.txt:
--------------------------------------------------------------------------------
1 | a: 500
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/9-call-default-scope-local-2.lua:
--------------------------------------------------------------------------------
1 | local function f1(a = 500) {
2 | print("a: " + a)
3 | }
4 |
5 | f1()
6 |
7 | if (2 > 1) {
8 |
9 | function f1(a = 600) {
10 | print("a: " + a)
11 | }
12 |
13 | f1()
14 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Functions/9-call-default-scope-local-2.txt:
--------------------------------------------------------------------------------
1 | a: 500
2 | a: 600
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/0-string.lua:
--------------------------------------------------------------------------------
1 | print("hello".upper())
2 | print("HELLO".lower())
3 | print("hello".reverse())
4 |
5 | function prototype.string.append(s)
6 | {
7 | return this + s;
8 | }
9 |
10 | print("hello".append(" world"));
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/0-string.txt:
--------------------------------------------------------------------------------
1 | HELLO
2 | hello
3 | olleh
4 | hello world
5 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/1-number.lua:
--------------------------------------------------------------------------------
1 | print((1.0).tostring())
2 | print((2.0).tostring())
3 |
4 | function prototype.number.double()
5 | {
6 | return this * 2;
7 | }
8 |
9 | print((2.0).double());
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/1-number.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | 4
4 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/2-boolean.lua:
--------------------------------------------------------------------------------
1 | print((true).tostring())
2 | print((false).tostring())
3 |
4 | prototype.boolean.invert = (bool) => !bool;
5 |
6 | print((true).invert())
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/2-boolean.txt:
--------------------------------------------------------------------------------
1 | true
2 | false
3 | false
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/3-table.lua:
--------------------------------------------------------------------------------
1 | function prototype.table.hello()
2 | {
3 | return "hello";
4 | }
5 |
6 | tbl = {}
7 | print(tbl.hello());
8 | //special case for tables, we only index the prototype for direct method calls
9 | //this should be nil
10 | print(tbl.hello)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/3-table.txt:
--------------------------------------------------------------------------------
1 | hello
2 | nil
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/4-range.lua:
--------------------------------------------------------------------------------
1 | function prototype.range.toTable()
2 | {
3 | local tbl = {}
4 | for(i in this) {
5 | table.insert(tbl, i);
6 | }
7 | return tbl;
8 | }
9 |
10 | print((1..4).toTable().length);
11 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Meta/4-range.txt:
--------------------------------------------------------------------------------
1 | 4
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/0-null-coalescing-assignment-min.lua:
--------------------------------------------------------------------------------
1 | a ??= 10
2 |
3 | print(a)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/0-null-coalescing-assignment-min.txt:
--------------------------------------------------------------------------------
1 | 10
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/1-null-coalescing-assignment-check.lua:
--------------------------------------------------------------------------------
1 | a ??= 10
2 | a ??= 20
3 |
4 | print(a)
5 |
6 | a = nil
7 |
8 | a ??= 50
9 |
10 | print(a)
11 |
12 | b ??= [5, 15, 30]
13 |
14 | print(b[0])
15 |
16 | b[0] ??= 50
17 |
18 | print(b[0])
19 |
20 | b["test"] ??= [7, 14]
21 |
22 | print(b["test"][0])
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/1-null-coalescing-assignment-check.txt:
--------------------------------------------------------------------------------
1 | 10
2 | 50
3 | 5
4 | 5
5 | 7
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/10-relax-ternary-chain-2.lua:
--------------------------------------------------------------------------------
1 | b = (1 > 2 && 300 > 5) || 100 == 100 ? 1 : 2
2 | print(b)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/10-relax-ternary-chain-2.txt:
--------------------------------------------------------------------------------
1 | 1
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/11-nill-coalescing-inverse.lua:
--------------------------------------------------------------------------------
1 | x = 10 ?! 100
2 | print(x)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/11-nill-coalescing-inverse.txt:
--------------------------------------------------------------------------------
1 | 100
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/12-nill-coalescing-assignment-inverse.lua:
--------------------------------------------------------------------------------
1 | x ?!= 500
2 | print(x)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/12-nill-coalescing-assignment-inverse.txt:
--------------------------------------------------------------------------------
1 | nil
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/13-nill-coalescing-assignment-inverse-ok.lua:
--------------------------------------------------------------------------------
1 | x = 10
2 | x ?!= 500
3 | print(x)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/13-nill-coalescing-assignment-inverse-ok.txt:
--------------------------------------------------------------------------------
1 | 500
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/14-length.lua:
--------------------------------------------------------------------------------
1 | print([1, 2, 3, 4].length)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/14-length.txt:
--------------------------------------------------------------------------------
1 | 4
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/16-for-range-exclusive.lua:
--------------------------------------------------------------------------------
1 | for (i in 1..<5) {
2 | print(i)
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/16-for-range-exclusive.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | 3
4 | 4
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/17-for-range-tbl-one-side.lua:
--------------------------------------------------------------------------------
1 | a = [1, 2, 3]
2 |
3 | for (i in 1..a[0]) {
4 | print(i)
5 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/17-for-range-tbl-one-side.txt:
--------------------------------------------------------------------------------
1 | 1
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/18-range-var.lua:
--------------------------------------------------------------------------------
1 | x = 1..2
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/18-range-var.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/18-range-var.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/19-range-var-print.lua:
--------------------------------------------------------------------------------
1 | x = 1..2
2 | print(x.to)
3 | print(x.from)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/19-range-var-print.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 1
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/2-null-coalescing-assignment-scope.lua:
--------------------------------------------------------------------------------
1 | function f1() {
2 | a ??= 500
3 | print(a)
4 | }
5 |
6 | f1();
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/2-null-coalescing-assignment-scope.txt:
--------------------------------------------------------------------------------
1 | 500
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/20-range-var-set.lua:
--------------------------------------------------------------------------------
1 | x = 1..2
2 | x.to = 3
3 | print(x.to)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/20-range-var-set.txt:
--------------------------------------------------------------------------------
1 | 3
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/3-null-coalescing-assignment-local.lua:
--------------------------------------------------------------------------------
1 | local a ??= 500
2 | print(a)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/3-null-coalescing-assignment-local.txt:
--------------------------------------------------------------------------------
1 | 500
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/4-null-coalescing-assignment-local-scope.lua:
--------------------------------------------------------------------------------
1 | f = () => {
2 | local a ??= 600
3 | a ??= 700
4 | print(a)
5 | }
6 |
7 | f();
8 | print(a)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/4-null-coalescing-assignment-local-scope.txt:
--------------------------------------------------------------------------------
1 | 600
2 | nil
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/5-null-coalescing-assignment-ternary-skip.lua:
--------------------------------------------------------------------------------
1 | b = 1
2 | b ??= (5 > 20) ? 10 : 20
3 |
4 | print(b)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/5-null-coalescing-assignment-ternary-skip.txt:
--------------------------------------------------------------------------------
1 | 1
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/6-null-coalescing-assignment-ternary-exec.lua:
--------------------------------------------------------------------------------
1 | b ??= (5 > 20) ? 10 : 20
2 |
3 | print(b)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/6-null-coalescing-assignment-ternary-exec.txt:
--------------------------------------------------------------------------------
1 | 20
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/7-relax-ternary.lua:
--------------------------------------------------------------------------------
1 | b = 5 > 20 ? 1 : 2
2 | print(b)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/7-relax-ternary.txt:
--------------------------------------------------------------------------------
1 | 2
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/8-relax-ternary-cmp.lua:
--------------------------------------------------------------------------------
1 | b = (5 > 20) ? 10 : 20
2 | print(b)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/8-relax-ternary-cmp.txt:
--------------------------------------------------------------------------------
1 | 20
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/9-relax-ternary-chain.lua:
--------------------------------------------------------------------------------
1 | b = 5 > 20 && 1 > 0 ? 1 : 2
2 | print(b)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Operators/9-relax-ternary-chain.txt:
--------------------------------------------------------------------------------
1 | 2
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/0-linesanity.lua:
--------------------------------------------------------------------------------
1 | print(CurrentLine())
2 | print(CurrentLine())
3 | print(CurrentLine())
4 | //SourceRef for call expressions = the ()
5 | //As the previous SourceRef is for the index instructions
6 | print(CurrentColumn())
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/0-linesanity.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | 3
4 | 19
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/1-ifdef.lua:
--------------------------------------------------------------------------------
1 | #if VARIABLE
2 | print(CurrentLine())
3 | #else
4 | print(CurrentLine())
5 | #endif
6 |
7 | #define VARIABLE
8 |
9 | #if VARIABLE
10 | print(CurrentLine())
11 | #else
12 | print(CurrentLine())
13 | #endif
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/1-ifdef.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 10
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/10-isdefined.lua:
--------------------------------------------------------------------------------
1 | #define VAR1
2 |
3 | #if defined(VAR1)
4 | print("ok")
5 | #else
6 | print("not ok VAR1")
7 | #endif
8 |
9 | #if !defined(VAR2)
10 | print("ok")
11 | #else
12 | print("not ok VAR2")
13 | #endif
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/10-isdefined.txt:
--------------------------------------------------------------------------------
1 | ok
2 | ok
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/11-coloffset.lua:
--------------------------------------------------------------------------------
1 | #line 3, 20
2 | /*20 char comment!*/print(CurrentColumn())
3 | // ^
4 | //source ref points to here (19)
5 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/11-coloffset.txt:
--------------------------------------------------------------------------------
1 | 19
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/2-ifndef.lua:
--------------------------------------------------------------------------------
1 | #if !VARIABLE
2 | print(CurrentLine())
3 | #else
4 | print(CurrentLine())
5 | #endif
6 |
7 | #define VARIABLE
8 |
9 | #if !VARIABLE
10 | print(CurrentLine())
11 | #else
12 | print(CurrentLine())
13 | #endif
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/2-ifndef.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 12
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/3-in-string.lua:
--------------------------------------------------------------------------------
1 | //#define inside a string literal won't be processed
2 | //but a #define in the expression will
3 |
4 | l = `
5 | #define HELLO
6 | {
7 | #define WORLD
8 | }
9 | `
10 | print(CurrentLine())
11 | #if HELLO
12 | print("hello")
13 | #endif
14 | #if WORLD
15 | print("world")
16 | #endif
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/3-in-string.txt:
--------------------------------------------------------------------------------
1 | 10
2 | world
3 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/4-and.lua:
--------------------------------------------------------------------------------
1 | #define VAR1
2 | #define VAR2
3 |
4 | #if VAR1 && VAR2
5 | print("ok")
6 | #else
7 | print ("not ok")
8 | #endif
9 |
10 | #if VAR1 && VAR3
11 | print("not ok")
12 | #else
13 | print("ok")
14 | #endif
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/4-and.txt:
--------------------------------------------------------------------------------
1 | ok
2 | ok
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/5-ops.lua:
--------------------------------------------------------------------------------
1 | #define A 5
2 | #define B 3
3 |
4 | #if A > B
5 | print("ok")
6 | #else
7 | print("not ok A > B")
8 | #endif
9 |
10 | #if A >= B
11 | print("ok")
12 | #else
13 | print("not ok A >= B")
14 | #endif
15 |
16 | #if B > A
17 | print("not ok B > A")
18 | #else
19 | print("ok")
20 | #endif
21 |
22 | #if B >= A
23 | print("not ok B >= A")
24 | #else
25 | print("ok")
26 | #endif
27 |
28 | #if A < B
29 | print("not ok A < B")
30 | #else
31 | print("ok")
32 | #endif
33 |
34 | #if A <= B
35 | print("not ok A <= B")
36 | #else
37 | print("ok")
38 | #endif
39 |
40 | #if B < A
41 | print("ok")
42 | #else
43 | print("not ok B < A")
44 | #endif
45 |
46 | #if B <= A
47 | print("ok")
48 | #else
49 | print("not ok B <= A")
50 | #endif
51 | print(CurrentLine())
52 |
53 | #if 23 > A
54 | print("ok")
55 | #else
56 | print("not ok 23 > A");
57 | #endif
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/5-ops.txt:
--------------------------------------------------------------------------------
1 | ok
2 | ok
3 | ok
4 | ok
5 | ok
6 | ok
7 | ok
8 | ok
9 | 51
10 | ok
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/6-simpleline.lua:
--------------------------------------------------------------------------------
1 | #line 7
2 | print(CurrentLine());
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | #line 300 /* Comment
11 | */
12 | print(CurrentLine());
13 |
14 | #line default
15 | print(CurrentLine())
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/6-simpleline.txt:
--------------------------------------------------------------------------------
1 | 7
2 | 301
3 | 15
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/7-values.lua:
--------------------------------------------------------------------------------
1 | #define STRING "hello"
2 | #define NUMBER 8.0
3 | #define BOOLEAN true
4 | #define NONE
5 |
6 | // Making sure "//" and '/*' within literals doesn't trigger comments
7 |
8 | #define STRING2 "//"
9 | #define STRING3 '/*'
10 |
11 | print(STRING)
12 | print(STRING2)
13 | print(STRING3)
14 | print(NUMBER)
15 | print(BOOLEAN)
16 | print(NONE)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/7-values.txt:
--------------------------------------------------------------------------------
1 | hello
2 | //
3 | /*
4 | 8
5 | true
6 | nil
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/9-multidef.lua:
--------------------------------------------------------------------------------
1 | #define STRING = "hello", EMPTY, STRING2 = "world"
2 |
3 | print(STRING)
4 | print(STRING2)
5 | print(EMPTY)
6 | #undef STRING, STRING2
7 |
8 | //we didn't undef empty, check it's still there
9 | #if EMPTY
10 | print("ok")
11 | #else
12 | print("not ok - EMPTY")
13 | #endif
14 |
15 | #if !STRING
16 | print("ok")
17 | #else
18 | print("not ok - STRING")
19 | #endif
20 |
21 | #if !STRING2
22 | print("ok")
23 | #else
24 | print("not ok - STRING2")
25 | #endif
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Preprocessor/9-multidef.txt:
--------------------------------------------------------------------------------
1 | hello
2 | world
3 | nil
4 | ok
5 | ok
6 | ok
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/1-for-range-inclusive.lua:
--------------------------------------------------------------------------------
1 | for (i in 1..5) {
2 | print(i)
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/1-for-range-inclusive.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/10-range-tbl-index.lua:
--------------------------------------------------------------------------------
1 | tbl = [1..10]
2 | print(tbl[0].to)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/10-range-tbl-index.txt:
--------------------------------------------------------------------------------
1 | 10
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/11-range-tbl-index-mixed.lua:
--------------------------------------------------------------------------------
1 | tbl = ["hello", 10, 1..10, 3..5]
2 | print(tbl.length)
3 | print(tbl[0])
4 | print(tbl[1])
5 | print(tbl[2].from)
6 | print(tbl[2].to)
7 | print(tbl[3].from)
8 | print(tbl[3].to)
9 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/11-range-tbl-index-mixed.txt:
--------------------------------------------------------------------------------
1 | 4
2 | hello
3 | 10
4 | 1
5 | 10
6 | 3
7 | 5
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/12-range-concat-invalid.lua:
--------------------------------------------------------------------------------
1 | r1 = 1..10
2 | r2 = 5..5
3 | r3 = r1 + r2;
4 | print(r3.from)
5 | print(r3.to)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/12-range-concat-invalid.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 15
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/13-range-tbl-add.lua:
--------------------------------------------------------------------------------
1 | r1 = 1..10
2 | tbl = [];
3 | table.insert(tbl, r1)
4 | print(tbl[0].to)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/13-range-tbl-add.txt:
--------------------------------------------------------------------------------
1 | 10
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/14-range-inline-add-invalid.lua:
--------------------------------------------------------------------------------
1 | r1 = 1..10 + 5..5
2 | print(r1.from)
3 | print(r1.to)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/14-range-inline-add-invalid.txt:
--------------------------------------------------------------------------------
1 | 6
2 | 15
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/15-range-multiple-vars.lua:
--------------------------------------------------------------------------------
1 | for (i, j in 1..2) {
2 | print(i + " " + j)
3 | }
4 | z = 100
5 | print("test stack ok " + z)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/15-range-multiple-vars.txt:
--------------------------------------------------------------------------------
1 | 1 1
2 | 2 2
3 | test stack ok 100
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/16-range-iter-ref.lua:
--------------------------------------------------------------------------------
1 | tbl = [10, 12]
2 |
3 | for (i in tbl[0]..tbl[1]) {
4 | print(i)
5 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/16-range-iter-ref.txt:
--------------------------------------------------------------------------------
1 | 10
2 | 11
3 | 12
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/17-range-vstack.lua:
--------------------------------------------------------------------------------
1 | x = 1..60000
2 | y = 0
3 | for (i in x) {
4 | y++
5 | }
6 | print(y)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/17-range-vstack.txt:
--------------------------------------------------------------------------------
1 | 60000
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/18-range-tuple.lua:
--------------------------------------------------------------------------------
1 | function mret() {
2 | return 1, 2;
3 | }
4 | print(mret() + mret()); // 2
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/18-range-tuple.txt:
--------------------------------------------------------------------------------
1 | 2
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/19-range-numval-low.lua:
--------------------------------------------------------------------------------
1 | x = 0
2 | for (i in -4095..0) {
3 | x++;
4 | }
5 | print(x)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/19-range-numval-low.txt:
--------------------------------------------------------------------------------
1 | 4096
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/2-for-range-left-exclusive.lua:
--------------------------------------------------------------------------------
1 | for (i in 1>..5) {
2 | print(i)
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/2-for-range-left-exclusive.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 3
3 | 4
4 | 5
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/20-range-var.lua:
--------------------------------------------------------------------------------
1 | a = 8
2 | b = 10
3 | for (i in a..b) {
4 | print(i)
5 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/20-range-var.txt:
--------------------------------------------------------------------------------
1 | 8
2 | 9
3 | 10
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/21-range-string.lua:
--------------------------------------------------------------------------------
1 | a = "4"
2 | b = "6"
3 | for (i in a..b) {
4 | print(i)
5 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/21-range-string.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 5
3 | 6
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/22-range-string-direct.lua:
--------------------------------------------------------------------------------
1 | for (i in "4".."6") {
2 | print(i)
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/22-range-string-direct.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 5
3 | 6
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/23-range-bool-invalid.lua:
--------------------------------------------------------------------------------
1 | for (i in 1..true) {
2 | print(i)
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/23-range-bool-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/23-range-bool-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/24-range-string-invalid.lua:
--------------------------------------------------------------------------------
1 | for (i in 1.."hi") {
2 | print(i)
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/24-range-string-invalid.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/24-range-string-invalid.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/3-for-range-right-exclusive.lua:
--------------------------------------------------------------------------------
1 | for (i in 1..<5) {
2 | print(i)
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/3-for-range-right-exclusive.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | 3
4 | 4
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/4-for-range-exclusive.lua:
--------------------------------------------------------------------------------
1 | for (i in 1>..<5) {
2 | print(i)
3 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/4-for-range-exclusive.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 3
3 | 4
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/5-range-var.lua:
--------------------------------------------------------------------------------
1 | myRange = 1 >..< 5
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/5-range-var.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WattleScript/wattlescript/90a70a4b0d5d0f314725df2733610cb522827cc8/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/5-range-var.txt
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/6-range-set.lua:
--------------------------------------------------------------------------------
1 | myRange = 1 >..< 5
2 | myRange.from = 1
3 | myRange.to = 5
4 |
5 | for (i in myRange) {
6 | print(i)
7 | }
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/6-range-set.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/7-range-get.lua:
--------------------------------------------------------------------------------
1 | myRange = 1..5
2 | print(myRange.from)
3 | print(myRange.to)
4 |
5 | myLeftExclusiveRange = 1..<5
6 | print(myLeftExclusiveRange.from)
7 | print(myLeftExclusiveRange.to)
8 |
9 | myRightExclusiveRange = 1>..5
10 | print(myRightExclusiveRange.from)
11 | print(myRightExclusiveRange.to)
12 |
13 | myExclusiveRange = 1>..<5
14 | print(myExclusiveRange.from)
15 | print(myExclusiveRange.to)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/7-range-get.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 5
3 | 1
4 | 4
5 | 2
6 | 5
7 | 2
8 | 4
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/8-range-chain.lua:
--------------------------------------------------------------------------------
1 | myRange = 2*2..2*2+1
2 | print(myRange.from)
3 | print(myRange.to)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/8-range-chain.txt:
--------------------------------------------------------------------------------
1 | 4
2 | 5
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/9-range-ref.lua:
--------------------------------------------------------------------------------
1 | tbl = [10, 20]
2 | myRange = tbl[0]..tbl[1]
3 | print(myRange.from)
4 | print(myRange.to)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Ranges/9-range-ref.txt:
--------------------------------------------------------------------------------
1 | 10
2 | 20
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/1-interpolated-string.lua:
--------------------------------------------------------------------------------
1 | world = 100
2 | x = `hello {world}`
3 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/1-interpolated-string.txt:
--------------------------------------------------------------------------------
1 | hello 100
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/10-unicode-auto.lua:
--------------------------------------------------------------------------------
1 | x = '\u2714aaaaaa'
2 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/10-unicode-auto.txt:
--------------------------------------------------------------------------------
1 | ✔aaaaaa
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/11-unicode-transition-multiple.lua:
--------------------------------------------------------------------------------
1 | x = '\u2714hi\u2714'
2 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/11-unicode-transition-multiple.txt:
--------------------------------------------------------------------------------
1 | ✔hi✔
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/11-unicode-transition.lua:
--------------------------------------------------------------------------------
1 | x = '\u2714hi'
2 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/11-unicode-transition.txt:
--------------------------------------------------------------------------------
1 | ✔hi
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/12-unicode-auto-hex.lua:
--------------------------------------------------------------------------------
1 | x = 'Click \u201CCustomize\u201D to'
2 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/12-unicode-auto-hex.txt:
--------------------------------------------------------------------------------
1 | Click “Customize” to
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/13-unicode-auto-two-sequences.lua:
--------------------------------------------------------------------------------
1 | x = 'music \uD834\uDD1E'
2 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/13-unicode-auto-two-sequences.txt:
--------------------------------------------------------------------------------
1 | music 𝄞
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/14-unicode-auto-two-sequences-2.lua:
--------------------------------------------------------------------------------
1 | x = 'music \uD834\uDD1E!'
2 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/14-unicode-auto-two-sequences-2.txt:
--------------------------------------------------------------------------------
1 | music 𝄞!
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/15-unicode-mixed.lua:
--------------------------------------------------------------------------------
1 | x = '\u2605\uD83D\uDE00\u2605'
2 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/15-unicode-mixed.txt:
--------------------------------------------------------------------------------
1 | ★😀★
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/2-interpolated-string-escape.lua:
--------------------------------------------------------------------------------
1 | world = 100
2 | x = `hello \{world\}`
3 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/2-interpolated-string-escape.txt:
--------------------------------------------------------------------------------
1 | hello {world}
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/3-interpolated-string-escape-backtick.lua:
--------------------------------------------------------------------------------
1 | world = 100
2 | x = `hello \`\``
3 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/3-interpolated-string-escape-backtick.txt:
--------------------------------------------------------------------------------
1 | hello ``
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/4-interpolated-string-expr.lua:
--------------------------------------------------------------------------------
1 | world = 100
2 | x = `hello {world > 50 ? "gt50" : "lt50"}`
3 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/4-interpolated-string-expr.txt:
--------------------------------------------------------------------------------
1 | hello gt50
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/5-interpolated-string-multiline.lua:
--------------------------------------------------------------------------------
1 | world = 100
2 | x = `hello
3 | greetings
4 | hi
5 | ahoj
6 | {world}
7 | \{
8 | \}
9 | \`
10 | "double quotes"
11 | 'single quotes'
12 | "''"
13 | `
14 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/5-interpolated-string-multiline.txt:
--------------------------------------------------------------------------------
1 | hello
2 | greetings
3 | hi
4 | ahoj
5 | 100
6 | {
7 | }
8 | `
9 | "double quotes"
10 | 'single quotes'
11 | "''"
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/6-interpolated-string-double.lua:
--------------------------------------------------------------------------------
1 | x = `unescaped \` in string`
2 | print(x)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/6-interpolated-string-double.txt:
--------------------------------------------------------------------------------
1 | unescaped ` in string
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/7-interpolated-string-multiple.lua:
--------------------------------------------------------------------------------
1 | x1 = 10
2 | x = `{x1}{x1}{x1}test{x1}`
3 | print(x)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/7-interpolated-string-multiple.txt:
--------------------------------------------------------------------------------
1 | 101010test10
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/8-unicode.lua:
--------------------------------------------------------------------------------
1 | x = '\u2714'
2 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/8-unicode.txt:
--------------------------------------------------------------------------------
1 | ✔
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/9-unicode-brk.lua:
--------------------------------------------------------------------------------
1 | x = '\u{2714}'
2 | print(x);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Strings/9-unicode-brk.txt:
--------------------------------------------------------------------------------
1 | ✔
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/0-switchbreak.lua:
--------------------------------------------------------------------------------
1 | function s1(a) {
2 | switch(a) {
3 | case 5:
4 | i = 0
5 | while true {
6 | i++
7 | if i > 3 {
8 | break;
9 | }
10 | }
11 | i = 7
12 | break;
13 | default:
14 | i = 99
15 | }
16 | }
17 |
18 | s1(5);
19 | print(i);
20 | s1(0);
21 | print(i);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/0-switchbreak.txt:
--------------------------------------------------------------------------------
1 | 7
2 | 99
3 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/1-multicaseswitch.lua:
--------------------------------------------------------------------------------
1 | function s1(arg) {
2 | switch(arg) {
3 | case 'd':
4 | case 'f':
5 | case 'e':
6 | print(1);
7 | case 'a':
8 | case 'b':
9 | case 'c':
10 | print(2);
11 | default:
12 | print('error');
13 | }
14 | }
15 | s1('a');
16 | s1('b');
17 | s1('c');
18 | s1('d');
19 | s1('e');
20 | s1('f');
21 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/1-multicaseswitch.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 2
3 | 2
4 | 1
5 | 1
6 | 1
7 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/2-gotocase.lua:
--------------------------------------------------------------------------------
1 | function s1(arg) {
2 | switch(arg) {
3 | case 'b':
4 | print('b');
5 | case 'a':
6 | print('a');
7 | goto case 'b';
8 | }
9 | }
10 |
11 | s1('a');
12 | s1('b');
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/2-gotocase.txt:
--------------------------------------------------------------------------------
1 | a
2 | b
3 | b
4 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/3-gotodefault.lua:
--------------------------------------------------------------------------------
1 | function s1(arg) {
2 | switch(arg) {
3 | case 1:
4 | print('a');
5 | goto default;
6 | case 2:
7 | print('b');
8 | default:
9 | print('c');
10 | }
11 | }
12 |
13 | s1(1);
14 | s1(2);
15 | s1(3);
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/3-gotodefault.txt:
--------------------------------------------------------------------------------
1 | a
2 | c
3 | b
4 | c
5 |
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/4-multicaseswitch-brks.lua:
--------------------------------------------------------------------------------
1 |
2 | function s1(arg) {
3 | switch(arg) {
4 | case 'd':
5 | case 'f':
6 | case 'e':
7 | {
8 | print(1);
9 | }
10 | case 'a':
11 | case 'b':
12 | case 'c': {
13 | print(2);
14 | }
15 | default:
16 | print('error');
17 | }
18 | }
19 | s1('a');
20 | s1('b');
21 | s1('c');
22 | s1('d');
23 | s1('e');
24 | s1('f');
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Switch/4-multicaseswitch-brks.txt:
--------------------------------------------------------------------------------
1 | 2
2 | 2
3 | 2
4 | 1
5 | 1
6 | 1
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Tables/1-double-square-brk.lua:
--------------------------------------------------------------------------------
1 | x = [[100]]
2 | print(x[0][0])
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxCLike/Tables/1-double-square-brk.txt:
--------------------------------------------------------------------------------
1 | 100
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/0-set.lua:
--------------------------------------------------------------------------------
1 | local tbl = {}
2 | tbl[0] = 80;
3 | print(tbl[0])
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/0-set.txt:
--------------------------------------------------------------------------------
1 | 80
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/01-set-double.lua:
--------------------------------------------------------------------------------
1 | local tbl = {}
2 | tbl[3] = 50;
3 | tbl[3.14] = 80;
4 | print(tbl[3])
5 | print(tbl[3.14])
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/01-set-double.txt:
--------------------------------------------------------------------------------
1 | 50
2 | 80
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/1-iterate.lua:
--------------------------------------------------------------------------------
1 | local tbl = {10, 20, 30}
2 | for k, v in ipairs(tbl) do
3 | print(v)
4 | end
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/1-iterate.txt:
--------------------------------------------------------------------------------
1 | 10
2 | 20
3 | 30
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/10-concat-from-to.lua:
--------------------------------------------------------------------------------
1 | local str = table.concat({ 1, 2, "three", 4, "five" }, "-", 0, 2)
2 | print(str)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/10-concat-from-to.txt:
--------------------------------------------------------------------------------
1 | 1-2
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/2-insert.lua:
--------------------------------------------------------------------------------
1 | local tbl = {}
2 | table.insert(tbl, 30)
3 |
4 | print(tbl[0])
5 |
6 | table.insert(tbl, 50)
7 |
8 | print(tbl[0])
9 | print(tbl[1])
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/2-insert.txt:
--------------------------------------------------------------------------------
1 | 30
2 | 30
3 | 50
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/3-sort-simple.lua:
--------------------------------------------------------------------------------
1 | local tbl = {90, 500, 0, 5}
2 | table.sort(tbl)
3 | print(tbl[0])
4 | print(tbl[1])
5 | print(tbl[2])
6 | print(tbl[3])
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/3-sort-simple.txt:
--------------------------------------------------------------------------------
1 | 0
2 | 5
3 | 90
4 | 500
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/4-remove.lua:
--------------------------------------------------------------------------------
1 | local tbl = {5, 10, 15, 20}
2 | table.remove(tbl)
3 | print(tbl[0])
4 | print(tbl[1])
5 | print(tbl[2])
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/4-remove.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 10
3 | 15
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/5-remove-index.lua:
--------------------------------------------------------------------------------
1 | local tbl = {5, 10, 15, 20}
2 | table.remove(tbl, 1)
3 | print(tbl[0])
4 | print(tbl[1])
5 | print(tbl[2])
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/5-remove-index.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 15
3 | 20
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/6-remove-index-multiple.lua:
--------------------------------------------------------------------------------
1 | local tbl = {5, 10, 15, 20}
2 | table.remove(tbl, 1)
3 | table.remove(tbl, 1)
4 | print(tbl[0])
5 | print(tbl[1])
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/6-remove-index-multiple.txt:
--------------------------------------------------------------------------------
1 | 5
2 | 20
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/7-concat.lua:
--------------------------------------------------------------------------------
1 | local str = table.concat({ 1, 2, "three", 4, "five" })
2 | print(str)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/7-concat.txt:
--------------------------------------------------------------------------------
1 | 12three4five
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/8-concat-from.lua:
--------------------------------------------------------------------------------
1 | local str = table.concat({ 1, 2, "three", 4, "five" }, "-", 1)
2 | print(str)
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/CLike/SyntaxLua/Tables/8-concat-from.txt:
--------------------------------------------------------------------------------
1 | 2-three-4-five
--------------------------------------------------------------------------------
/src/WattleScript.Interpreter.Tests/EndToEnd/FunctionTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 |
5 | namespace WattleScript.Interpreter.Tests.EndToEnd
6 | {
7 | [TestFixture]
8 | public class FunctionTests
9 | {
10 | DynValue ListFilter(Script sc, CallbackArguments args)
11 | {
12 | Table tbl = new Table(sc);
13 | DynValue dv = DynValue.NewTable(tbl);
14 |
15 | Table toFilter = args[0].Table;
16 | Closure filterFn = args[1].Function;
17 |
18 | foreach (TablePair pair in toFilter.Pairs)
19 | {
20 | DynValue valPair = pair.Value;
21 | DynValue check = filterFn.Call(valPair);
22 |
23 | if (check.Boolean)
24 | {
25 | tbl.Append(valPair);
26 | }
27 | }
28 |
29 | return dv;
30 | }
31 |
32 | [Test]
33 | public void ListFilter()
34 | {
35 | string script = @"
36 | arr = list_filter({10, 20, 30}, function (x) return x >= 20 end)
37 | return arr[1]
38 | ";
39 |
40 | var sc = new Script();
41 | sc.Globals["list_filter"] = (Func