API Basic Class ko - LIHACHTETAN/ClassicUO-BadNewbie-BasicIDE GitHub Wiki
Class / New / Me / Property
ClassicUO โข Basic
Class๋ ๊ฐ์ฒด๋ณ ์ํ์ ์คํฌ๋ฆฝํธ ๋ฉ์๋๋ฅผ ๋ฌถ์ต๋๋ค. New๋ ์ฐธ์กฐ ๊ฐ์ฒด๋ฅผ ์์ฑํฉ๋๋ค. ๋ค๋ฅธ ๋ณ์์ ๋์ ํด๋ ๊ฐ์ ๊ฐ์ฒด๋ฅผ ๊ฐ๋ฆฌํค๋ฉฐ, Structure์ ๊ฐ ๋ณต์ฌ์ ๋ค๋ฆ ๋๋ค. ์์ ์ ์ฌ์ฉํ๋ ์์ฑ์, ๋ฉ์๋, ์์ฑ ์ ๊ทผ์๋ฅผ ๋ชจ๋ ์ ์ํฉ๋๋ค.
์ ํํ ๊ตฌ๋ฌธ
[Public | Private] Class TypeName
[Public | Private | Dim] field As FieldType
Public Sub New([parameters]) ... End Sub
[Public | Private] Sub Method([parameters]) ... End Sub
[Public | Private] Function Method([parameters]) As ResultType ... End Function
[Public | Private] [ReadOnly | WriteOnly] Property Name[()] As ValueType
Get ... Return value / Name = value / Exit Property ... End Get
Set(ByVal value As ValueType) ... End Set
End Property
Public Property AutoName As ValueType
End Class
Dim instance [As TypeName] = New TypeName(arguments)
instance.Property = expression
value = instance.Property
instance.Method(arguments)
With instance ... End With
๋งค๊ฐ๋ณ์
TypeName / Public / Privateโ TypeName์ ํ์ผ ๋๋ Module ์์ค์ ๊ณ ์ ํ ๋จ์ ์ด๋ฆ์ ๋๋ค. ๋ชจ๋ ๋ฐ์์๋ ModuleName.TypeName์ ์ฌ์ฉํฉ๋๋ค. Class ๊ธฐ๋ณธ๊ฐ์ Public์ด๋ฉฐ Private Class๋ ์์ ์ Module์๋ง ๋ณด์ ๋๋ค. ์์, ์ธํฐํ์ด์ค, ์ ๋ค๋ฆญ, ์ค์ฒฉ ํด๋์ค, Shared, ์ค๋ฒ๋ก๋, ์๋ฉธ์, ์ธ์คํด์ค Event ์ ์ธ์ ๊ตฌํ๋์ง ์์์ต๋๋ค.field As FieldType / Meโ ํ๋๋ As Integer, Double, Boolean, String, Object ๋๋ ์ ์ธ๋ Enum/Structure/Class ํ์์ด ํ์ํฉ๋๋ค. ๊ธฐ์กด Basic ํ์ ๋ณ์นญ๋ ์ ํจํฉ๋๋ค. ํ๋๋ ๊ธฐ๋ณธ Private์ด๋ฏ๋ก ์ธ๋ถ ์ ๊ทผ์๋ Public์ ๋ช ์ํฉ๋๋ค. ์ด๊ธฐ๊ฐ์ ์ซ์/Boolean 0, String ๋น ๋ฌธ์์ด, Structure ์๊ฐ ํ๋, Object/Class Nothing(Unit)์ ๋๋ค. ๋ค๋ฅธ ์ด๊ธฐํ๋ Sub New์์ ํฉ๋๋ค. Me๋ ํ์ฌ ์ธ์คํด์ค์ด๋ฉฐ ์ฌ์ ์ธยท์ฌ๋์ ํ ์ ์์ต๋๋ค. ๋งค๊ฐ๋ณ์์ ์ง์ญ ๋ณ์๋ ๋ค๋ฅธ ๋ฉค๋ฒ ์ด๋ฆ์ ๊ฐ๋ฆด ์ ์์ต๋๋ค.New / Sub Newโ New TypeName(arguments)๋ ๋ณ๋ ํ๋๋ฅผ ๋ง๋ค๊ณ Public Sub New๋ฅผ ํ ๋ฒ ์คํํฉ๋๋ค. ์์ฑ์๊ฐ ์์ผ๋ฉด New TypeName()๋ง ํ์ฉํฉ๋๋ค. ์์ฑ์๋ ํ๋์ด๋ฉฐ ์ผ๋ฐ Optional, ๊ธฐ๋ณธ๊ฐ, ๋ช ๋ช ๋ ์ธ์ ๊ท์น์ ๋ฐ๋ฆ ๋๋ค. ์ธ์๋ ์์ฑ ์์๋๋ก ํ ๋ฒ ํ๊ฐ๋๋ฉฐ ์คํจํ๋ฉด ์์ฑ๋ ๊ฐ์ฒด๋ฅผ ๋ฐํํ์ง ์์ต๋๋ค. As TypeName๋ง ์ ์ธํ ๋ณ์๋ Nothing์ ๋๋ค.Sub / Function / argumentsโ Sub/Function์ instance.Method(...), ํด๋์ค ๋ด๋ถ์์๋ Method(...)/Me.Method(...)๋ก ํธ์ถํฉ๋๋ค. Private์ ๊ฐ์ Class ์ฝ๋์์๋ง ํธ์ถํ๋ฉฐ ๊ฐ์ ํ์์ ๋ค๋ฅธ ์ธ์คํด์ค์๋ ์ ์ฉ๋ฉ๋๋ค. ํ์, ByVal/ByRef, Optional, ParamArray, ๋ช ๋ช ๋ ์ธ์๋ฅผ ์ง์ํ๋ ParamArray ์์์ ์ด๋ฆ ์ง์ ์ ๋ถ๊ฐํฉ๋๋ค. Function์ ์ ์ธ ํ์, Sub๋ Unit์ ๋ฐํํฉ๋๋ค. TypeName.Method(...)์ instance.New(...)๋ ์๋ชป๋ ํธ์ถ์ ๋๋ค. ์ธ์คํด์ค ๋ฉ์๋์ AddressOf์๋ ํ์ผ/๋ชจ๋ ๋ํผ ํ๋ก์์ ๊ฐ ํ์ํฉ๋๋ค.Property / Get / Setโ Property Name[()] As ValueType์๋ ์ธ๋ฑ์ค ๋งค๊ฐ๋ณ์๊ฐ ์์ต๋๋ค. ์ฝ๊ธฐ๋ ํธ์ถ ๊ดํธ ์์ด instance.Name์ ๋๋ค. Get์ Return ๋๋ Name ๋์ ์ผ๋ก ๋ฐํํ๊ณ Exit Property๋ ๊ทธ ๊ฒฐ๊ณผ๋ ๊ธฐ๋ณธ๊ฐ์ ๋ฐํํฉ๋๋ค. ๋์ ์ Set(ByVal value As ValueType)์ ์คํํ๋ฉฐ ๋ง์ง๋ง Get์ ์ฝ์ง ์์ต๋๋ค. ์ผ๋ฐ ์์ฑ์ Get/Set์ ํ๋์ฉ ์๊ตฌํฉ๋๋ค. ์ ๊ทผ ๋ฒ์๋ Property์ ์ง์ ํ๊ณ Set์ ๊ฐ์ ํ์์ ๋ช ์์ ์ธ ByVal ๋งค๊ฐ๋ณ์ ํ๋๊ฐ ํ์ํฉ๋๋ค.ReadOnly / WriteOnly / auto Propertyโ ๋ณธ๋ฌธ์ด ์๋ ReadOnly๋ Get๋ง, WriteOnly๋ Set๋ง ํฌํจํฉ๋๋ค. ๊ธ์ง๋ ์ ๊ทผ์ ์ก์ ์ ์๋ ์ค๋ฅ์ ๋๋ค. ์๋ ์์ฑ์ Get/Set๊ณผ End Property ์์ด ๊ฐ์ ์ง์ ์ ์ฅํฉ๋๋ค. ์๋ ReadOnly๋ ํด๋น ์ธ์คํด์ค์ Sub New์์๋ง ๋์ ํ ์ ์๊ณ Set ์๋ WriteOnly๋ ๋ฌดํจ์ ๋๋ค. ReadOnly๊ฐ Class ์ฐธ์กฐ๋ฅผ ๋ฐํํด๋ ์ฐธ์กฐ ๋์์ ๋ณ๊ฒฝ ๊ฐ๋ฅํ ๋ฉค๋ฒ๋ ์์ ํ ์ ์์ต๋๋ค.ByVal / ByRef / Withโ ByVal์ ์ฐธ์กฐ๋ฅผ ๋ณต์ฌํฉ๋๋ค. ๋ฉค๋ฒ ๋ณ๊ฒฝ์ ์๋ณธ์ ์ํฅ์ ์ฃผ์ง๋ง ๋งค๊ฐ๋ณ์ ๊ต์ฒด๋ ํธ์ถ์ ๋ณ์๋ฅผ ๊ต์ฒดํ์ง ์์ต๋๋ค. ByRef๋ ์์ง์ copy-in/copy-out ๊ท์น์ ๋ฐ๋ผ ์ ์ฐธ์กฐ๋ ๋์๋๋ค. ๋๋ฑ ๋น๊ต๋ ๊ฐ์ฒด ๋์ผ์ฑ์ ๋๋ค. With instance๋ ๊ฐ์ฒด๋ฅผ ํ ๋ฒ ์บก์ฒํ์ฌ ํ๋ยท์์ฑยท๋ฉ์๋์ ์ฌ์ฉํฉ๋๋ค. Class๋ ์๋ IDisposable์ด ์๋๋ฏ๋ก Using์ ์ง์๋๋ ๋ฆฌ์์ค ๊ฐ์ฒด์ ์ ์ฉํฉ๋๋ค.
๋ฐํ๊ฐ
New๋ Class ์ฐธ์กฐ๋ฅผ ๋ด์ Object๋ฅผ ๋ฐํํ๋ฉฐ UO ID/๊ทธ๋ํฝ์ด ์๋๋๋ค. Get/Function์ ์ ์ธ ํ์, Set/Sub/์ ์ธ์ Unit์ ๋๋ค. New ์๋ ๋ณ์๋ Nothing์ ๋๋ค. ์ฐธ์กฐ ๋์ผ์ฑ๊ณผ As Boolean์ 1/True ๋๋ 0/False์ด๊ณ Integer ์๋์ ์๋ ์ฑ๊ณต ํ๋๊ทธ๊ฐ ์๋๋๋ค. Main ๊ฒฐ๊ณผ: "5:2:1", "1:0:6", "ore:1:replacement:0".
๋์
- SC032๋ Option Explicit ์์ด๋ ์๋ชป๋ ์ ์ธ์ ์คํ ์ ์ ๊ฑฐ๋ถํฉ๋๋ค. ํ๋: ํด๋์ค 256๊ฐ, ํด๋์ค๋ณ ํ๋/์์ฑ 256๊ฐ์ ๋ฉ์๋ 256๊ฐ, New/Get/Set์ ํฌํจํ ์ค์ฒฉ ํธ์ถ 32๋จ๊ณ. ๋์ /ByRef ๊ฒฝ๋ก๋ 64๊ฐ ๊ตฌ์ฑ ์์๊น์ง์ ๋๋ค. ์ํ ์ฐธ์กฐ๋ ํ์ฉํฉ๋๋ค. ๋ฉํ๋ฐ์ดํฐยท๊ธฐ๋ณธ๊ฐ์ ๋ฏธ๋ฆฌ ์ค๋นํ๊ณ ๋ณ๊ฒฝ ๊ฐ๋ฅํ ์ ์ฅ์๋ ๊ฐ New๋ง๋ค ๋ฐ๋ก ๋ง๋ญ๋๋ค.
- ๋์ ๊ฒฝ๋ก๋ฅผ ์ค๋ฅธ์ชฝ ์/์ธ์์ ๋ถ์ ํจ๊ณผ ์ ์ ์บก์ฒํ์ฌ ๊ฒฝ๋ก์ ๊ฐ Get์ ํ ๋ฒ ํ๊ฐํฉ๋๋ค. ํ๋ก์์ ๊ฐ ์ค๊ฐ ๋ณ์๋ฅผ ๊ต์ฒดํด๋ ๋์ฐ๊ธฐ ๋์์ ์๋ ๊ฐ์ฒด์ ๋๋ค. ๊ฐ์ ์ ์ธ ํ์์ผ๋ก ๋ณํํฉ๋๋ค. ์์ฑ์ยท๋ฉ์๋ยท์ ๊ทผ์ ์ค๋ฅ๋ Try/Catch๋ก ์ฒ๋ฆฌํ๋ฉฐ ์ด์ ๋ณ๊ฒฝ์ ์ทจ์ํ์ง ์์ต๋๋ค.
- ์ผ์ ์ค์งยท์ ์งยท์์ค ์์นยท๊น์ด ์ ํ์ ์ผ๋ฐ ์คํฌ๋ฆฝํธ ํ๋ ์์ ์ฌ์ฉํฉ๋๋ค. IDE๋ง ๋ซ์์๋ ์คํฌ๋ฆฝํธ๊ฐ ๋ฉ์ถ์ง ์์ต๋๋ค. ๊ฒ์ฌ๊ธฐ๋ Get ์คํ์ด๋ ์ํ ํ์ ์์ด ํ์๊ณผ ๋ฉค๋ฒ ์๋ฅผ ํ์ํฉ๋๋ค. Watch๋ ์ ์ฅ ํ๋/์๋ ์์ฑ์ ์ฝ์ ์ ์์ง๋ง ์ฌ์ฉ์ Get, ๋ฉ์๋, ์์ฑ์๋ฅผ ์คํํ ์ ์์ต๋๋ค. ์์ .NET ํด๋์ค๊ฐ ์๋ ์ค๋ช ๋ Basic ๋ถ๋ถ์งํฉ์ ๋๋ค.
์์
1. ๋ ๋ฆฝ ๊ฐ์ฒด์ ๊ณต์ ์ฐธ์กฐ
# New Counter(label:="ore", start:=2)๋ String label๊ณผ Integer start๋ฅผ ์ ๋ฌํ๊ณ Label/stored๋ฅผ ์ค์ ํฉ๋๋ค. second์๋ ๋
๋ฆฝ ํ๋๊ฐ ์๊ณ alias=first๋ ์ฐธ์กฐ ๋ณต์ฌ์
๋๋ค. Add(amount:=3)๋ Value.Set์ผ๋ก ์์๋ฅผ ๊ฒ์ฌํ๊ณ ์ด ๋ค Value.Get์ Integer๋ฅผ ๋ฐํํฉ๋๋ค. first=5, second=2, alias=first๋ 1/True์
๋๋ค. ๋ชจ๋ ๋์ฐ๋ฏธ ๋ฉ์๋๋ฅผ ํฌํจํฉ๋๋ค.
Option Explicit On
Class Counter
Private stored As Integer
Public Property Label As String
Public Sub New(ByVal label As String, ByVal start As Integer)
Me.Label = label
stored = start
End Sub
Public Property Value As Integer
Get
Return stored
End Get
Set(ByVal value As Integer)
If value < 0 Then
Throw "Value must be non-negative"
End If
stored = value
End Set
End Property
Public Function Add(ByVal amount As Integer) As Integer
Me.Value = stored + amount
Return Me.Value
End Function
End Class
Sub Main()
Dim first = New Counter(label:="ore", start:=2)
Dim second = New Counter("wood", 2)
Dim alias = first
alias.Add(amount:=3)
Return CStr(first.Value) & ":" & CStr(second.Value) & ":" & CStr(alias = first)
End Sub
๋งค๊ฐ๋ณ์ ๋ฐ ์คํ ์ค๋ช :
New Counter(label:="ore", start:=2)๋ String label๊ณผ Integer start๋ฅผ ์ ๋ฌํ๊ณ Label/stored๋ฅผ ์ค์ ํฉ๋๋ค. second์๋ ๋ ๋ฆฝ ํ๋๊ฐ ์๊ณ alias=first๋ ์ฐธ์กฐ ๋ณต์ฌ์ ๋๋ค. Add(amount:=3)๋ Value.Set์ผ๋ก ์์๋ฅผ ๊ฒ์ฌํ๊ณ ์ด ๋ค Value.Get์ Integer๋ฅผ ๋ฐํํฉ๋๋ค. first=5, second=2, alias=first๋ 1/True์ ๋๋ค. ๋ชจ๋ ๋์ฐ๋ฏธ ๋ฉ์๋๋ฅผ ํฌํจํฉ๋๋ค.
2. ์ฝ๊ธฐยท์ฐ๊ธฐ์ Boolean
# Limit=10์ value=10์ผ๋ก Set์ ํธ์ถํฉ๋๋ค. Remaining.Get์ ๊ฒฐ๊ณผ ์ด๋ฆ์ ๋์
ํ๊ณ Exit Property๋ก ๋ฐํํฉ๋๋ค. TrySpend(cost:=4)๋ 4๋ฅผ ๋นผ๊ณ 1/True, cost=9๋ ๋จ์ 6๋ณด๋ค ์ปค์ 0/False์
๋๋ค. Limit=-3์ ์ ์ฅ ์ ์ ์ค๋ฅ๋ฅผ ๋ด๊ณ Catch๋ Remaining=6์ ์ฝ์ต๋๋ค. Main์ "1:0:6"์ด๋ฉฐ ์๋ฒ ๋์์ ์์ต๋๋ค.
Option Explicit On
Class Budget
Private amount As Integer
Public ReadOnly Property Remaining() As Integer
Get
Remaining = amount
Exit Property
End Get
End Property
Public WriteOnly Property Limit As Integer
Set(ByVal value As Integer)
If value < 0 Then
Throw "Limit must be non-negative"
End If
amount = value
End Set
End Property
Public Function TrySpend(ByVal cost As Integer) As Boolean
If cost < 0 Then
Throw "cost must be non-negative"
End If
If cost > amount Then
Return False
End If
amount -= cost
Return True
End Function
End Class
Sub Main()
Dim budget = New Budget()
budget.Limit = 10
Dim paid = budget.TrySpend(4)
Dim refused = budget.TrySpend(9)
Try
budget.Limit = -3
Catch problem
Return CStr(paid) & ":" & CStr(refused) & ":" & CStr(budget.Remaining)
End Try
Return "unexpected"
End Sub
๋งค๊ฐ๋ณ์ ๋ฐ ์คํ ์ค๋ช :
Limit=10์ value=10์ผ๋ก Set์ ํธ์ถํฉ๋๋ค. Remaining.Get์ ๊ฒฐ๊ณผ ์ด๋ฆ์ ๋์ ํ๊ณ Exit Property๋ก ๋ฐํํฉ๋๋ค. TrySpend(cost:=4)๋ 4๋ฅผ ๋นผ๊ณ 1/True, cost=9๋ ๋จ์ 6๋ณด๋ค ์ปค์ 0/False์ ๋๋ค. Limit=-3์ ์ ์ฅ ์ ์ ์ค๋ฅ๋ฅผ ๋ด๊ณ Catch๋ Remaining=6์ ์ฝ์ต๋๋ค. Main์ "1:0:6"์ด๋ฉฐ ์๋ฒ ๋์์ ์์ต๋๋ค.
3. Module, ByVal, ByRef ๊ต์ฒด
# Jobs.WorkItem(name)์ String Name์ ์ ์ฅํ๊ณ Done์ 0์ผ๋ก ์์ํฉ๋๋ค. Tick(ByVal job)์ ๊ณต์ Done์ 1๋ก ๋ง๋ค์ง๋ง ๋ค์ "local" ๊ต์ฒด๋ ์ง์ญ ๋งค๊ฐ๋ณ์์๋ง ์ ์ฉ๋ฉ๋๋ค. Replace(ByRef job, ByVal name)์ "replacement"๋ฅผ ์์ฑํ์ฌ ํธ์ถ์ ์ฐธ์กฐ๋ฅผ ๋์๋๋ค. ๋ช
๋ช
๋ ์ธ์๋ฅผ ์๋์ ์ผ๋ก ์ญ์์ผ๋ก ์ ๋ฌํฉ๋๋ค. original์ "ore"/1์ด๊ณ job์ ์๋ก์ด "replacement"/0์
๋๋ค. Module Jobs ์ ์ฒด๋ฅผ ์ ์ํฉ๋๋ค.
Option Explicit On
Module Jobs
Public Class WorkItem
Public Property Name As String
Public Done As Integer
Public Sub New(ByVal name As String)
Me.Name = name
End Sub
End Class
Public Sub Tick(ByVal job As WorkItem)
job.Done += 1
job = New WorkItem("local")
End Sub
Public Sub Replace(ByRef job As WorkItem, ByVal name As String)
job = New WorkItem(name)
End Sub
End Module
Sub Main()
Dim job As Jobs.WorkItem = New Jobs.WorkItem("ore")
Dim original = job
Jobs.Tick(job)
Jobs.Replace(name:="replacement", job:=job)
Return original.Name & ":" & CStr(original.Done) & ":" & job.Name & ":" & CStr(job.Done)
End Sub
๋งค๊ฐ๋ณ์ ๋ฐ ์คํ ์ค๋ช :
Jobs.WorkItem(name)์ String Name์ ์ ์ฅํ๊ณ Done์ 0์ผ๋ก ์์ํฉ๋๋ค. Tick(ByVal job)์ ๊ณต์ Done์ 1๋ก ๋ง๋ค์ง๋ง ๋ค์ "local" ๊ต์ฒด๋ ์ง์ญ ๋งค๊ฐ๋ณ์์๋ง ์ ์ฉ๋ฉ๋๋ค. Replace(ByRef job, ByVal name)์ "replacement"๋ฅผ ์์ฑํ์ฌ ํธ์ถ์ ์ฐธ์กฐ๋ฅผ ๋์๋๋ค. ๋ช ๋ช ๋ ์ธ์๋ฅผ ์๋์ ์ผ๋ก ์ญ์์ผ๋ก ์ ๋ฌํฉ๋๋ค. original์ "ore"/1์ด๊ณ job์ ์๋ก์ด "replacement"/0์ ๋๋ค. Module Jobs ์ ์ฒด๋ฅผ ์ ์ํฉ๋๋ค.
๋ด๋ถ ํจ์: ํธ์ถ๋ถํฐ ๊ฒฐ๊ณผ๊น์ง
Class๋ ๊ฐ์ฒด๋ณ ์ํ์ ์คํฌ๋ฆฝํธ ๋ฉ์๋๋ฅผ ๋ฌถ์ต๋๋ค. New๋ ์ฐธ์กฐ ๊ฐ์ฒด๋ฅผ ์์ฑํฉ๋๋ค. ๋ค๋ฅธ ๋ณ์์ ๋์ ํด๋ ๊ฐ์ ๊ฐ์ฒด๋ฅผ ๊ฐ๋ฆฌํค๋ฉฐ, Structure์ ๊ฐ ๋ณต์ฌ์ ๋ค๋ฆ ๋๋ค. ์์ ์ ์ฌ์ฉํ๋ ์์ฑ์, ๋ฉ์๋, ์์ฑ ์ ๊ทผ์๋ฅผ ๋ชจ๋ ์ ์ํฉ๋๋ค.
1. ClassCatalog.Build / Complete
SC032๋ Option Explicit ์์ด๋ ์๋ชป๋ ์ ์ธ์ ์คํ ์ ์ ๊ฑฐ๋ถํฉ๋๋ค. ํ๋: ํด๋์ค 256๊ฐ, ํด๋์ค๋ณ ํ๋/์์ฑ 256๊ฐ์ ๋ฉ์๋ 256๊ฐ, New/Get/Set์ ํฌํจํ ์ค์ฒฉ ํธ์ถ 32๋จ๊ณ. ๋์ /ByRef ๊ฒฝ๋ก๋ 64๊ฐ ๊ตฌ์ฑ ์์๊น์ง์ ๋๋ค. ์ํ ์ฐธ์กฐ๋ ํ์ฉํฉ๋๋ค. ๋ฉํ๋ฐ์ดํฐยท๊ธฐ๋ณธ๊ฐ์ ๋ฏธ๋ฆฌ ์ค๋นํ๊ณ ๋ณ๊ฒฝ ๊ฐ๋ฅํ ์ ์ฅ์๋ ๊ฐ New๋ง๋ค ๋ฐ๋ก ๋ง๋ญ๋๋ค.
declarations -> unique typed members -> accessor validation -> prepared metadata; SC032 on invalid Class
ํ๋ก์ ํธ ์์ค: external/InjectionScript/src/InjectionScript/Runtime/ClassCatalog.cs; ํจ์ ClassCatalog.Build / Complete.
2. ConstructClass
New TypeName(arguments)๋ ๋ณ๋ ํ๋๋ฅผ ๋ง๋ค๊ณ Public Sub New๋ฅผ ํ ๋ฒ ์คํํฉ๋๋ค. ์์ฑ์๊ฐ ์์ผ๋ฉด New TypeName()๋ง ํ์ฉํฉ๋๋ค. ์์ฑ์๋ ํ๋์ด๋ฉฐ ์ผ๋ฐ Optional, ๊ธฐ๋ณธ๊ฐ, ๋ช ๋ช ๋ ์ธ์ ๊ท์น์ ๋ฐ๋ฆ ๋๋ค. ์ธ์๋ ์์ฑ ์์๋๋ก ํ ๋ฒ ํ๊ฐ๋๋ฉฐ ์คํจํ๋ฉด ์์ฑ๋ ๊ฐ์ฒด๋ฅผ ๋ฐํํ์ง ์์ต๋๋ค. As TypeName๋ง ์ ์ธํ ๋ณ์๋ Nothing์ ๋๋ค.
new instance -> independent field slots -> bind constructor arguments -> Sub New -> Object reference
ํ๋ก์ ํธ ์์ค: external/InjectionScript/src/InjectionScript/Runtime/Interpreter.Classes.cs; ํจ์ ConstructClass.
3. ClassObject.Member / Read
Property Name[()] As ValueType์๋ ์ธ๋ฑ์ค ๋งค๊ฐ๋ณ์๊ฐ ์์ต๋๋ค. ์ฝ๊ธฐ๋ ํธ์ถ ๊ดํธ ์์ด instance.Name์ ๋๋ค. Get์ Return ๋๋ Name ๋์ ์ผ๋ก ๋ฐํํ๊ณ Exit Property๋ ๊ทธ ๊ฒฐ๊ณผ๋ ๊ธฐ๋ณธ๊ฐ์ ๋ฐํํฉ๋๋ค. ๋์ ์ Set(ByVal value As ValueType)์ ์คํํ๋ฉฐ ๋ง์ง๋ง Get์ ์ฝ์ง ์์ต๋๋ค. ์ผ๋ฐ ์์ฑ์ Get/Set์ ํ๋์ฉ ์๊ตฌํฉ๋๋ค. ์ ๊ทผ ๋ฒ์๋ Property์ ์ง์ ํ๊ณ Set์ ๊ฐ์ ํ์์ ๋ช ์์ ์ธ ByVal ๋งค๊ฐ๋ณ์ ํ๋๊ฐ ํ์ํฉ๋๋ค.
check member visibility -> stored value OR Get frame -> declared value type
ํ๋ก์ ํธ ์์ค: external/InjectionScript/src/InjectionScript/Runtime/ObjectTypes/ClassObject.cs; ํจ์ ClassObject.Member / Read.
4. MemberAccess.Resolve / ClassObject.Write
๋์ ๊ฒฝ๋ก๋ฅผ ์ค๋ฅธ์ชฝ ์/์ธ์์ ๋ถ์ ํจ๊ณผ ์ ์ ์บก์ฒํ์ฌ ๊ฒฝ๋ก์ ๊ฐ Get์ ํ ๋ฒ ํ๊ฐํฉ๋๋ค. ํ๋ก์์ ๊ฐ ์ค๊ฐ ๋ณ์๋ฅผ ๊ต์ฒดํด๋ ๋์ฐ๊ธฐ ๋์์ ์๋ ๊ฐ์ฒด์ ๋๋ค. ๊ฐ์ ์ ์ธ ํ์์ผ๋ก ๋ณํํฉ๋๋ค. ์์ฑ์ยท๋ฉ์๋ยท์ ๊ทผ์ ์ค๋ฅ๋ Try/Catch๋ก ์ฒ๋ฆฌํ๋ฉฐ ์ด์ ๋ณ๊ฒฝ์ ์ทจ์ํ์ง ์์ต๋๋ค.
capture receiver once -> evaluate RHS/arguments -> coerce value -> Set OR stored slot
ํ๋ก์ ํธ ์์ค: external/InjectionScript/src/InjectionScript/Runtime/MemberAccess.cs; ํจ์ MemberAccess.Resolve / ClassObject.Write.
5. CallClassMethod / CallSubrutine
Sub/Function์ instance.Method(...), ํด๋์ค ๋ด๋ถ์์๋ Method(...)/Me.Method(...)๋ก ํธ์ถํฉ๋๋ค. Private์ ๊ฐ์ Class ์ฝ๋์์๋ง ํธ์ถํ๋ฉฐ ๊ฐ์ ํ์์ ๋ค๋ฅธ ์ธ์คํด์ค์๋ ์ ์ฉ๋ฉ๋๋ค. ํ์, ByVal/ByRef, Optional, ParamArray, ๋ช ๋ช ๋ ์ธ์๋ฅผ ์ง์ํ๋ ParamArray ์์์ ์ด๋ฆ ์ง์ ์ ๋ถ๊ฐํฉ๋๋ค. Function์ ์ ์ธ ํ์, Sub๋ Unit์ ๋ฐํํฉ๋๋ค. TypeName.Method(...)์ instance.New(...)๋ ์๋ชป๋ ํธ์ถ์ ๋๋ค. ์ธ์คํด์ค ๋ฉ์๋์ AddressOf์๋ ํ์ผ/๋ชจ๋ ๋ํผ ํ๋ก์์ ๊ฐ ํ์ํฉ๋๋ค.
check method visibility -> bind named/positional arguments -> Me frame -> return -> ByRef copy-out
ํ๋ก์ ํธ ์์ค: external/InjectionScript/src/InjectionScript/Runtime/Interpreter.Classes.cs; ํจ์ CallClassMethod / CallSubrutine.
6. ClassObject.DisplayValue
์ผ์ ์ค์งยท์ ์งยท์์ค ์์นยท๊น์ด ์ ํ์ ์ผ๋ฐ ์คํฌ๋ฆฝํธ ํ๋ ์์ ์ฌ์ฉํฉ๋๋ค. IDE๋ง ๋ซ์์๋ ์คํฌ๋ฆฝํธ๊ฐ ๋ฉ์ถ์ง ์์ต๋๋ค. ๊ฒ์ฌ๊ธฐ๋ Get ์คํ์ด๋ ์ํ ํ์ ์์ด ํ์๊ณผ ๋ฉค๋ฒ ์๋ฅผ ํ์ํฉ๋๋ค. Watch๋ ์ ์ฅ ํ๋/์๋ ์์ฑ์ ์ฝ์ ์ ์์ง๋ง ์ฌ์ฉ์ Get, ๋ฉ์๋, ์์ฑ์๋ฅผ ์คํํ ์ ์์ต๋๋ค. ์์ .NET ํด๋์ค๊ฐ ์๋ ์ค๋ช ๋ Basic ๋ถ๋ถ์งํฉ์ ๋๋ค.
debugger: type + member count; no getter calls and no traversal of reference cycles
ํ๋ก์ ํธ ์์ค: external/InjectionScript/src/InjectionScript/Runtime/ObjectTypes/ClassObject.cs; ํจ์ ClassObject.DisplayValue.
New๋ Class ์ฐธ์กฐ๋ฅผ ๋ด์ Object๋ฅผ ๋ฐํํ๋ฉฐ UO ID/๊ทธ๋ํฝ์ด ์๋๋๋ค. Get/Function์ ์ ์ธ ํ์, Set/Sub/์ ์ธ์ Unit์ ๋๋ค. New ์๋ ๋ณ์๋ Nothing์ ๋๋ค. ์ฐธ์กฐ ๋์ผ์ฑ๊ณผ As Boolean์ 1/True ๋๋ 0/False์ด๊ณ Integer ์๋์ ์๋ ์ฑ๊ณต ํ๋๊ทธ๊ฐ ์๋๋๋ค. Main ๊ฒฐ๊ณผ: "5:2:1", "1:0:6", "ore:1:replacement:0".