1 |
#Region "Microsoft.VisualBasic::592555dd2c6e5c688ee4eb66f89500f4, Microsoft.VisualBasic.Core\Language\Runtime.vb"
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
#End Region
|
57 |
|
58 |
Imports System.Runtime.CompilerServices
|
59 |
Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic
|
60 |
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel.Repository
|
61 |
Imports Microsoft.VisualBasic.Emit.Delegates
|
62 |
Imports Microsoft.VisualBasic.Language.Default
|
63 |
|
64 |
Namespace Language
|
65 |
|
66 |
Public Class ArgumentReference : Implements INamedValue
|
67 |
|
68 |
Public name$, value
|
69 |
|
70 |
Private Property Key As String Implements IKeyedEntity(Of String).Key
|
71 |
Get
|
72 |
Return name
|
73 |
End Get
|
74 |
Set(value As String)
|
75 |
name = value
|
76 |
End Set
|
77 |
End Property
|
78 |
|
79 |
Public ReadOnly Property Expression(Optional null$ = "Nothing",
|
80 |
Optional stringEscaping As Func(Of String, String) = Nothing,
|
81 |
Optional isVar As Assert(Of String) = Nothing) As String
|
82 |
Get
|
83 |
Dim val$
|
84 |
|
85 |
Static [isNot] As New DefaultValue(Of Assert(Of String))(Function(var) False)
|
86 |
|
87 |
If value Is Nothing Then
|
88 |
val = null
|
89 |
ElseIf value.GetType Is GetType(String) Then
|
90 |
If (isVar Or [isNot])(value) Then
|
91 |
val = value
|
92 |
Else
|
93 |
val = $"""{(stringEscaping Or noEscaping)(value)}"""
|
94 |
End If
|
95 |
ElseIf value.GetType Is GetType(Char) Then
|
96 |
val = $"""{value}"""
|
97 |
Else
|
98 |
val = value
|
99 |
End If
|
100 |
|
101 |
Return $"{name} = {val}"
|
102 |
End Get
|
103 |
End Property
|
104 |
|
105 |
Public Overrides Function ToString() As String
|
106 |
Return $"Dim {name} As Object = {Scripting.ToString(value, "null")}"
|
107 |
End Function
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
<MethodImpl(MethodImplOptions.AggressiveInlining)>
|
116 |
Public Shared Operator =(var As ArgumentReference, value As Object) As ArgumentReference
|
117 |
var.value = value
|
118 |
Return var
|
119 |
End Operator
|
120 |
|
121 |
Public Shared Operator <>(var As ArgumentReference, value As Object) As ArgumentReference
|
122 |
Throw New NotImplementedException
|
123 |
End Operator
|
124 |
End Class
|
125 |
|
126 |
Public Class TypeSchema
|
127 |
|
128 |
Public ReadOnly Property Type As Type
|
129 |
|
130 |
Sub New(type As Type)
|
131 |
Me.Type = type
|
132 |
End Sub
|
133 |
|
134 |
Public Overrides Function ToString() As String
|
135 |
Return Type.FullName
|
136 |
End Function
|
137 |
|
138 |
<MethodImpl(MethodImplOptions.AggressiveInlining)>
|
139 |
Public Overloads Shared Operator And(info As TypeSchema, types As Type()) As Boolean
|
140 |
Return types.All(Function(t) Equals(info.Type, base:=t))
|
141 |
End Operator
|
142 |
|
143 |
Private Overloads Shared Function Equals(info As Type, base As Type) As Boolean
|
144 |
If info.IsInheritsFrom(base) Then
|
145 |
Return True
|
146 |
Else
|
147 |
If base.IsInterface AndAlso info.ImplementInterface(base) Then
|
148 |
Return True
|
149 |
Else
|
150 |
Return False
|
151 |
End If
|
152 |
End If
|
153 |
End Function
|
154 |
|
155 |
<MethodImpl(MethodImplOptions.AggressiveInlining)>
|
156 |
Public Overloads Shared Operator Or(info As TypeSchema, types As Type()) As Boolean
|
157 |
Return types.Any(Function(t) Equals(info.Type, base:=t))
|
158 |
End Operator
|
159 |
End Class
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
```vbnet
|
165 |
Imports VB = Microsoft.VisualBasic.Language.Runtime
|
166 |
|
167 |
With New VB
|
168 |
|
169 |
End With
|
170 |
```
|
171 |
|
172 |
Public Class Runtime
|
173 |
|
174 |
|
175 |
Language syntax supports for argument list
|
176 |
|
177 |
<param name="name$"></param>
|
178 |
|
179 |
Default Public ReadOnly Property Argument(name$) As ArgumentReference
|
180 |
<MethodImpl(MethodImplOptions.AggressiveInlining)>
|
181 |
Get
|
182 |
Return New ArgumentReference With {
|
183 |
.name = name
|
184 |
}
|
185 |
End Get
|
186 |
End Property
|
187 |
|
188 |
Public Overrides Function ToString() As String
|
189 |
Return "sciBASIC for VB.NET language runtime API"
|
190 |
End Function
|
191 |
End Class
|
192 |
End Namespace
|