Skip to content

Commit 9e466ab

Browse files
committed
Add Qtyi.Lua project
1 parent abd56ec commit 9e466ab

File tree

10 files changed

+256
-57
lines changed

10 files changed

+256
-57
lines changed

CoreFx.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analyzers", "Analyzers", "{
1111
EndProject
1212
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Qtyi.Lang.CodeStyle", "src\analyzers\Qtyi.Lang.CodeStyle\Qtyi.Lang.CodeStyle.csproj", "{3F64B9E4-919C-457F-BDCE-3695CA84D979}"
1313
EndProject
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Qtyi.Lua", "src\libraries\Qtyi.Lua\Qtyi.Lua.csproj", "{F87CBFAF-A025-4C7F-AD71-04EF43CD119F}"
15+
EndProject
1416
Global
1517
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1618
Debug|Any CPU = Debug|Any CPU
@@ -29,6 +31,10 @@ Global
2931
{3F64B9E4-919C-457F-BDCE-3695CA84D979}.Debug|Any CPU.Build.0 = Debug|Any CPU
3032
{3F64B9E4-919C-457F-BDCE-3695CA84D979}.Release|Any CPU.ActiveCfg = Release|Any CPU
3133
{3F64B9E4-919C-457F-BDCE-3695CA84D979}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{F87CBFAF-A025-4C7F-AD71-04EF43CD119F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{F87CBFAF-A025-4C7F-AD71-04EF43CD119F}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{F87CBFAF-A025-4C7F-AD71-04EF43CD119F}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{F87CBFAF-A025-4C7F-AD71-04EF43CD119F}.Release|Any CPU.Build.0 = Release|Any CPU
3238
EndGlobalSection
3339
GlobalSection(SolutionProperties) = preSolution
3440
HideSolutionNode = FALSE

eng/config/BannedSymbols.txt

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +0,0 @@
1-
T:Microsoft.VisualStudio.Shell.Interop.IComWrapper; Use Microsoft.VisualStudio.LanguageServices.Implementation.Interop.IComWrapperFixed instead
2-
P:Microsoft.CodeAnalysis.Completion.CompletionContext.Options; Use CompletionOptions instead.
3-
P:Microsoft.CodeAnalysis.Completion.CompletionList.Items; Use CompletionList.ItemsList instead
4-
M:Microsoft.CodeAnalysis.Completion.CompletionProvider.ShouldTriggerCompletion(Microsoft.CodeAnalysis.Text.SourceText,System.Int32,Microsoft.CodeAnalysis.Completion.CompletionTrigger,Microsoft.CodeAnalysis.Options.OptionSet); Use internal overload instead
5-
M:Microsoft.CodeAnalysis.Completion.CompletionProvider.GetDescriptionAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.Completion.CompletionItem,System.Threading.CancellationToken); Use internal overload instead
6-
M:Microsoft.CodeAnalysis.Completion.CompletionService.FilterItems(Microsoft.CodeAnalysis.Document,System.Collections.Immutable.ImmutableArray{Microsoft.CodeAnalysis.Completion.CompletionItem},System.String); Use internal overload instead
7-
M:Microsoft.CodeAnalysis.Completion.CompletionService.GetCompletionsAsync(Microsoft.CodeAnalysis.Document,System.Int32,Microsoft.CodeAnalysis.Completion.CompletionTrigger,System.Collections.Immutable.ImmutableHashSet{System.String},Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use internal overload instead
8-
M:Microsoft.CodeAnalysis.Completion.CompletionService.GetDescriptionAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.Completion.CompletionItem,System.Threading.CancellationToken); Use internal overload instead
9-
M:Microsoft.CodeAnalysis.Completion.CompletionService.GetRules; Use internal overload instead
10-
M:Microsoft.CodeAnalysis.QuickInfo.QuickInfoService.GetQuickInfoAsync(Microsoft.CodeAnalysis.Document,System.Int32,System.Threading.CancellationToken); Use internal overload instead
11-
M:Microsoft.CodeAnalysis.CodeFixes.FixAllContext.#ctor(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider,Microsoft.CodeAnalysis.CodeFixes.FixAllScope,System.String,System.Collections.Generic.IEnumerable{System.String},Microsoft.CodeAnalysis.CodeFixes.FixAllContext.DiagnosticProvider,System.Threading.CancellationToken); Use internal overload instead
12-
M:Microsoft.CodeAnalysis.CodeFixes.FixAllContext.#ctor(Microsoft.CodeAnalysis.Document,System.Nullable{Microsoft.CodeAnalysis.Text.TextSpan},Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider,Microsoft.CodeAnalysis.CodeFixes.FixAllScope,System.String,System.Collections.Generic.IEnumerable{System.String},Microsoft.CodeAnalysis.CodeFixes.FixAllContext.DiagnosticProvider,System.Threading.CancellationToken); Use internal overload instead
13-
M:Microsoft.CodeAnalysis.CodeFixes.FixAllContext.#ctor(Microsoft.CodeAnalysis.Project,Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider,Microsoft.CodeAnalysis.CodeFixes.FixAllScope,System.String,System.Collections.Generic.IEnumerable{System.String},Microsoft.CodeAnalysis.CodeFixes.FixAllContext.DiagnosticProvider,System.Threading.CancellationToken); Use internal overload instead
14-
M:Microsoft.CodeAnalysis.Document.GetOptionsAsync(System.Threading.CancellationToken); Use Document.GetAnalyzerConfigOptionsAsync instead
15-
T:Microsoft.CodeAnalysis.Options.DocumentOptionSet; Use AnalyzerConfigOptions instead
16-
M:Microsoft.VisualStudio.Shell.ServiceExtensions.GetService``2(System.IServiceProvider); Use RoslynServiceExtensions instead. This extension internally relies on ThreadHelper, which is incompatible with testing.
17-
M:Microsoft.VisualStudio.Shell.ServiceExtensions.GetService``2(System.IServiceProvider,System.Boolean); Use RoslynServiceExtensions instead. This extension internally relies on ThreadHelper, which is incompatible with testing
18-
M:Microsoft.VisualStudio.Shell.ServiceExtensions.GetServiceAsync``2(Microsoft.VisualStudio.Shell.IAsyncServiceProvider); Use RoslynServiceExtensions instead. This extension internally relies on ThreadHelper, which is incompatible with testing
19-
M:Microsoft.VisualStudio.Shell.ServiceExtensions.GetServiceAsync``2(Microsoft.VisualStudio.Shell.IAsyncServiceProvider,System.Boolean); Use RoslynServiceExtensions instead. This extension internally relies on ThreadHelper, which is incompatible with testing
20-
P:Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory; Use IThreadingContext.JoinableTaskFactory instead.
21-
M:Microsoft.CodeAnalysis.Formatting.Formatter.FormatAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use internal overload instead
22-
M:Microsoft.CodeAnalysis.Formatting.Formatter.FormatAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.Text.TextSpan,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
23-
M:Microsoft.CodeAnalysis.Formatting.Formatter.FormatAsync(Microsoft.CodeAnalysis.Document,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Text.TextSpan},Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
24-
M:Microsoft.CodeAnalysis.Formatting.Formatter.FormatAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.SyntaxAnnotation,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
25-
M:Microsoft.CodeAnalysis.Formatting.Formatter.Format(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxAnnotation,Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
26-
M:Microsoft.CodeAnalysis.Formatting.Formatter.Format(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
27-
M:Microsoft.CodeAnalysis.Formatting.Formatter.Format(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.Text.TextSpan,Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
28-
M:Microsoft.CodeAnalysis.Formatting.Formatter.Format(Microsoft.CodeAnalysis.SyntaxNode,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Text.TextSpan},Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
29-
M:Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattedTextChanges(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
30-
M:Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattedTextChanges(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.Text.TextSpan,Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
31-
M:Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattedTextChanges(Microsoft.CodeAnalysis.SyntaxNode,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Text.TextSpan},Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
32-
M:Microsoft.CodeAnalysis.Formatting.Formatter.OrganizeImportsAsync(Microsoft.CodeAnalysis.Document,System.Threading.CancellationToken); Call IOrganizeImportsService.OrganizeImportsAsync directly
33-
M:Microsoft.CodeAnalysis.Simplification.Simplifier.ReduceAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload that takes SimplifierOptions
34-
M:Microsoft.CodeAnalysis.Simplification.Simplifier.ReduceAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.SyntaxAnnotation,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload that takes SimplifierOptions
35-
M:Microsoft.CodeAnalysis.Simplification.Simplifier.ReduceAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.Text.TextSpan,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload that takes SimplifierOptions
36-
M:Microsoft.CodeAnalysis.Simplification.Simplifier.ReduceAsync(Microsoft.CodeAnalysis.Document,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Text.TextSpan},Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload that takes SimplifierOptions
37-
M:Microsoft.CodeAnalysis.Editing.SyntaxEditor.#ctor(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.Host.HostWorkspaceServices); Use overload that takes HostSolutionServices instead
38-
M:Microsoft.CodeAnalysis.FileTextLoader.#ctor(System.String,System.Text.Encoding); use WorkspaceFileTextLoader that calls on ITextFactoryService to create SourceText
39-
M:Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SyntaxTree(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding); Use CSharpSyntaxTree sublass that takes checksum algorithm
40-
M:Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(System.String,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding,System.Threading.CancellationToken); Use CSharpSyntaxTree sublass that takes checksum algorithm
41-
M:Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.CreateWithoutClone(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode); Use CSharpSyntaxTree sublass that takes checksum algorithm
42-
M:Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.Create(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options, System.String path, System.Text.Encoding encoding); Use CSharpSyntaxTree sublass that takes checksum algorithm
43-
M:Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(System.String,Microsoft.CodeAnalysis.CSharp.CSharpParseOptions,System.String,System.Text.Encoding,System.Threading.CancellationToken); Use API that takes SourceText
44-
M:Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(System.String,Microsoft.CodeAnalysis.CSharp.CSharpParseOptions,System.String,System.Text.Encoding,System.Collections.Immutable.ImmutableDictionary{System.String,Microsoft.CodeAnalysis.ReportDiagnostic},System.Nullable{System.Boolean},System.Threading.CancellationToken); Use API that takes SourceText
45-
M:Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.SyntaxTree(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
46-
M:Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.ParseSyntaxTree(System.String,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding,System.Threading.CancellationToken); Use overload with SourceText
47-
M:Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.ParseSyntaxTree(System.String,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding,System.Collections.Immutable.ImmutableDictionary{System.String,Microsoft.CodeAnalysis.ReportDiagnostic},System.Threading.CancellationToken); Use overload with SourceText
48-
M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.CreateWithoutClone(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
49-
M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.Create(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode,Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions,System.String,System.Text.Encoding,System.Collections.Immutable.ImmutableDictionary{System.String,Microsoft.CodeAnalysis.ReportDiagnostic}); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
50-
M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.Create(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode,Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions,System.String,System.Text.Encoding); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
51-
M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.ParseText(System.String,Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions,System.String,System.Text.Encoding,System.Collections.Immutable.ImmutableDictionary{System.String,Microsoft.CodeAnalysis.ReportDiagnostic},System.Threading.CancellationToken); Use overload with SourceText
52-
M:Microsoft.CodeAnalysis.Workspaces.Workspace.SetCurrentSolution(Microsoft.CodeAnalysis.Solution); Use SetCurrentSolutionEx instead.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Licensed to the Qtyi under one or more agreements.
2+
// The Qtyi licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Runtime.CompilerServices;
6+
7+
namespace Qtyi.Runtime;
8+
9+
public class ArgumentException : Exception
10+
{
11+
public ArgumentException(Object? value, int index, Type expectedType, [CallerMemberName] string callerMemberName = "") :
12+
this(value, index, new TypeInfo(expectedType), callerMemberName)
13+
{ }
14+
15+
public ArgumentException(Object? value, int index, TypeInfo expectedType, [CallerMemberName] string callerMemberName = "") :
16+
base($"bad argument #{index} to '{callerMemberName}' ({expectedType} expected, got {value?.GetTypeInfo() ?? TypeInfo.Nil})")
17+
{ }
18+
}

src/libraries/Qtyi.Lang.CoreLib/Primitive/TypeInfo.cs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public sealed class TypeInfo : Object, IEquatable<TypeInfo>, IEquatable<String>,
1616
public const string TypeInfo_Nil = "nil";
1717
public const string TypeInfo_Boolean = "boolean";
1818
public const string TypeInfo_Number = "number";
19+
public const string TypeInfo_Integer = "integer";
20+
public const string TypeInfo_Float = "float";
1921
public const string TypeInfo_String = "string";
2022
public const string TypeInfo_Function = "function";
2123
public const string TypeInfo_Userdata = "userdata";
@@ -25,6 +27,8 @@ public sealed class TypeInfo : Object, IEquatable<TypeInfo>, IEquatable<String>,
2527
public static readonly TypeInfo Nil = new(BasicType.Nil);
2628
public static readonly TypeInfo Boolean = new(BasicType.Boolean);
2729
public static readonly TypeInfo Number = new(BasicType.Number);
30+
public static readonly TypeInfo Integer = new(BasicType.Integer);
31+
public static readonly TypeInfo Float = new(BasicType.Float);
2832
public static readonly TypeInfo String = new(BasicType.String);
2933
public static readonly TypeInfo Function = new(BasicType.Function);
3034
public static readonly TypeInfo Userdata = new(BasicType.Userdata);
@@ -39,7 +43,9 @@ internal TypeInfo(string name)
3943
{
4044
TypeInfo_Nil => null,
4145
TypeInfo_Boolean => typeof(Boolean),
42-
TypeInfo_Number => typeof(Number),
46+
TypeInfo_Number or
47+
TypeInfo_Integer or
48+
TypeInfo_Float => typeof(Number),
4349
TypeInfo_String => typeof(String),
4450
TypeInfo_Function => typeof(Function),
4551
TypeInfo_Userdata => typeof(Userdata),
@@ -56,8 +62,16 @@ internal TypeInfo(Type? type)
5662
this._name = TypeInfo_Nil;
5763
else if (type == typeof(Boolean))
5864
this._name = TypeInfo_Boolean;
59-
else if (type == typeof(Number))
60-
this._name = TypeInfo_Number;
65+
else if (typeof(Number).IsAssignableFrom(type))
66+
{
67+
this._type = typeof(Number);
68+
if (type == typeof(Integer) || type == typeof(LargeInteger))
69+
this._name = TypeInfo_Integer;
70+
else if (type == typeof(Real) || type == typeof(DecimalReal))
71+
this._name = TypeInfo_Float;
72+
else
73+
this._name = TypeInfo_Number;
74+
}
6175
else if (type == typeof(String))
6276
this._name = TypeInfo_String;
6377
else if (type == typeof(Function))
@@ -110,9 +124,24 @@ protected internal override Table? Metatable
110124
};
111125
public bool Equals(string? other) => other is not null && this._name == other;
112126
public bool Equals(String? other) => other is not null && this._name == (string)other;
113-
public bool Equals(TypeInfo? other) => other is not null && (this._name == other._name && this._type == other._type);
127+
public bool Equals(TypeInfo? other)
128+
{
129+
if (other is null)
130+
return false;
131+
else if (this._type is null && other._type is null)
132+
return this._name == other._name;
133+
else
134+
return this._type == other._type;
135+
}
114136

115-
public override int GetHashCode() => this._name.GetHashCode() ^ (this._type is null ? 0 : this._type.GetHashCode());
137+
public override int GetHashCode()
138+
{
139+
var hashCode = this._name.GetHashCode();
140+
if (this._type is not null)
141+
hashCode = HashCode.Combine(hashCode, this._type.GetHashCode());
142+
143+
return hashCode;
144+
}
116145

117146
public override string ToString() => this._name;
118147

@@ -133,6 +162,8 @@ public enum BasicType
133162
Nil,
134163
Boolean,
135164
Number,
165+
Integer,
166+
Float,
136167
String,
137168
Function,
138169
Userdata,

src/libraries/Qtyi.Lang.CoreLib/Qtyi.Lang.CoreLib.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
<ApplyNgenOptimization Condition="'$(TargetFramework)' == 'netstandard2.0'">full</ApplyNgenOptimization>
1212
</PropertyGroup>
1313

14+
<ItemGroup>
15+
<Compile Include="..\..\shared\IsExternalInit.cs" Link="System.Runtime.CompilerServices\IsExternalInit.cs" />
16+
</ItemGroup>
17+
1418
<ItemGroup>
1519
<InternalsVisibleTo Include="Qtyi.Lang.CoreLib.UnitTests" />
1620
</ItemGroup>

0 commit comments

Comments
 (0)