-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompilerMessage.bmx
40 lines (33 loc) · 986 Bytes
/
CompilerMessage.bmx
1
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
SuperStrict
Type TCompilerMessage Final ' TODO: turn into struct?
Field ReadOnly message:String
Private
Method New(message:String)
Self.message = message
End Method
Public
Method Format:String(args:String[] = [])
Local messageStr:String = message.ToString()
? Debug
Local vars:Int = 0
For Local c:Int = 0 Until messageStr.length
If messageStr[c] = "$"[0] Then vars :+ 1
Next
Assert vars = args.length Else "Wrong number of arguments for message"
?
Local messageStrWithArgs:String = ""
Local a:Int = 0
Local s:Int = 0
For Local c:Int = 0 Until messageStr.length
If messageStr[c] = "$"[0] Then
messageStrWithArgs :+ messageStr[s..c]
messageStrWithArgs :+ formatArgs[a]
s = c
a :+ 1
End If
Next
If s <> messageStr.length - 1 Then messageStrWithArgs :+ messageStr[s..]
Return messageStrWithArgs
End Method
Global :TCompilerMessage = New TCompilerMessage("Include")
End Type