config.bmx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. ' Copyright (c) 2013-2024 Bruce A Henderson
  2. '
  3. ' Based on the public domain Monkey "trans" by Mark Sibly
  4. '
  5. ' This software is provided 'as-is', without any express or implied
  6. ' warranty. In no event will the authors be held liable for any damages
  7. ' arising from the use of this software.
  8. '
  9. ' Permission is granted to anyone to use this software for any purpose,
  10. ' including commercial applications, and to alter it and redistribute it
  11. ' freely, subject to the following restrictions:
  12. '
  13. ' 1. The origin of this software must not be misrepresented; you must not
  14. ' claim that you wrote the original software. If you use this software
  15. ' in a product, an acknowledgment in the product documentation would be
  16. ' appreciated but is not required.
  17. '
  18. ' 2. Altered source versions must be plainly marked as such, and must not be
  19. ' misrepresented as being the original software.
  20. '
  21. ' 3. This notice may not be removed or altered from any source
  22. ' distribution.
  23. '
  24. SuperStrict
  25. Import BRL.LinkedList
  26. Import BRL.Map
  27. Import BRL.FileSystem
  28. Import BRL.Math
  29. Import "options.bmx"
  30. Import "base.stringhelper.bmx"
  31. Import "base64.bmx"
  32. Import "enums.c"
  33. Import "hash.c"
  34. Import "math.c"
  35. Import "zlib/zlib.bmx"
  36. ' debugging help
  37. Const DEBUG:Int = False
  38. Const ABORT_ON_NULL:Int = True
  39. Const PROFILER:Int = False
  40. Const DEBUGSTOP_ON_ERROR:Int = False
  41. Const SHOW_INTERNALERR_LOCATION:Int = True
  42. Global ENV_LANG$
  43. Global _errInfo$
  44. Global _errStack:TList = New TList
  45. ' bytes offset to the first field
  46. Global OBJECT_BASE_OFFSET:Int = 8
  47. ' 4 bytes on 32-bit, 8 bytes on 64-bit
  48. Global POINTER_SIZE:Int = 4
  49. Global _symbols$[]=[ "..","[]",":*",":/",":+",":-",":|",":&",":~~",":shr",":shl",":sar",":mod"]
  50. Global _symbols_map$[]=[ "..","[]","*=","/=","+=","-=","|=","&=","^=",">>=", "<<=",">>=","%=" ]
  51. Global _fileHasher:TFileHash
  52. Function PushErr( errInfo$ )
  53. _errStack.AddLast _errInfo
  54. _errInfo=errInfo
  55. End Function
  56. Function PopErr()
  57. _errInfo=String(_errStack.RemoveLast())
  58. End Function
  59. Function Err( err$ )
  60. If DEBUGSTOP_ON_ERROR Then
  61. DebugStop ' useful for debugging!
  62. End If
  63. Throw "Compile Error: "+err + "~n" + _errInfo + "~n"
  64. End Function
  65. Function Warn( err$ )
  66. 'If DEBUGSTOP_ON_ERROR Then
  67. ' DebugStop ' useful for debugging!
  68. 'End If
  69. Print "Compile Warning: "+err + "~n" + _errInfo + "~n"
  70. End Function
  71. Function FormatError:String(path:String, line:Int, char:Int)
  72. Return "[" + path + ";" + line + ";" + char + "]"
  73. End Function
  74. Function InternalErr(errorLocation:String)
  75. If DEBUGSTOP_ON_ERROR Then
  76. DebugStop ' useful for debugging!
  77. End If
  78. Local locationMsg:String
  79. If SHOW_INTERNALERR_LOCATION And errorLocation Then locationMsg = " in " + errorLocation
  80. Throw "Compile Error: Internal Error" + locationMsg + ".~nPlease report the issue, with an example if possible, to https://github.com/bmx-ng/bcc/issues/new~n" + _errInfo + "~n"
  81. End Function
  82. Function IsSpace:Int( ch:Int )
  83. Return ch<=Asc(" ") Or ch=$A0 ' NO-BREAK SPACE (U+00A0)
  84. End Function
  85. Function IsDigit:Int( ch:Int )
  86. Return ch>=Asc("0") And ch<=Asc("9")
  87. End Function
  88. Function IsAlpha:Int( ch:Int )
  89. Return (ch>=Asc("A") And ch<=Asc("Z")) Or (ch>=Asc("a") And ch<=Asc("z"))
  90. End Function
  91. Function IsBinDigit:Int( ch:Int )
  92. Return ch=Asc("0") Or ch=Asc("1")
  93. End Function
  94. Function IsHexDigit:Int( ch:Int )
  95. Return IsDigit(ch) Or (ch>=Asc("A") And ch<=Asc("F")) Or (ch>=Asc("a") And ch<=Asc("f"))
  96. End Function
  97. Function Todo()
  98. Err "TODO!"
  99. End Function
  100. Function StringToLong:Long(value:String)
  101. Local Sign:Int = 1
  102. Local i:Int
  103. While i < value.length And (value[i] = Asc("+") Or value[i] = Asc("-"))
  104. If value[i] = Asc("-") Then
  105. Sign = -1
  106. End If
  107. i :+ 1
  108. Wend
  109. Local n:Long = 0
  110. While i < value.length
  111. Local c:Int = value[i]
  112. If Not IsDigit(c) Exit
  113. n = n * 10 + (c-Asc("0"))
  114. i :+ 1
  115. Wend
  116. Return n
  117. End Function
  118. Function IsStandardFunc:Int(func:String)
  119. func = func.ToLower()
  120. Global funcs:String = ";isalnum;isalpha;isascii;isblank;iscntrl;isdigit;isgraph;islower;isprint;ispunct;isspace;isupper;isxdigit;" + ..
  121. "strlen;_wgetenv;_wputenv;"
  122. Return funcs.Find(func) > 0
  123. End Function
  124. Function mapSymbol:String(sym:String)
  125. For Local i:Int = 0 Until _symbols.length
  126. If sym = _symbols[i] Then
  127. Return _symbols_map[i]
  128. End If
  129. Next
  130. Return sym
  131. End Function
  132. 'enquote depending on ENV_LANG
  133. '
  134. Function LangEnquote$( str$ )
  135. str=EscapeString(str)
  136. ' str=str.Replace( "~0","\0" ) 'Fix me?
  137. For Local i:Int=0 Until str.Length
  138. If str[i]>=32 And str[i]<128 Continue
  139. Local t$,n:Int=str[i]
  140. While n
  141. Local c:Int=(n&15)+48
  142. If c>=58 c:+97-58
  143. t=Chr( c )+t
  144. n=(n Shr 4) & $0fffffff
  145. Wend
  146. If Not t t="0"
  147. If ENV_LANG = "cpp" Then
  148. 'Case "cpp"
  149. t="~q~q\x"+t+"~q~q"
  150. Else
  151. t="\u"+("0000"+t)[-4..]
  152. End If
  153. str=str[..i]+t+str[i+1..]
  154. i:+t.Length-1
  155. Next
  156. str="~q"+str+"~q"
  157. If ENV_LANG="cpp" str="L"+str
  158. Return str
  159. End Function
  160. Function EscapeString$(str$)
  161. str=str.Replace( "\","\\" )
  162. str=str.Replace( "~q","\~q" )
  163. str=str.Replace( "~n","\n" )
  164. str=str.Replace( "~r","\r" )
  165. str=str.Replace( "~t","\t" )
  166. Return str
  167. End Function
  168. Function EscapeLines:String(str:String)
  169. str=str.Replace("~n", "Newline")
  170. Return str
  171. End Function
  172. Function BmxEnquote$( str$ )
  173. str=str.Replace( "~~","~~~~" )
  174. str=str.Replace( "~q","~~q" )
  175. str=str.Replace( "~n","~~n" )
  176. str=str.Replace( "~r","~~r" )
  177. str=str.Replace( "~t","~~t" )
  178. str=str.Replace( "~0","~~0" )
  179. str="~q"+str+"~q"
  180. Return str
  181. End Function
  182. Function BmxUnquote$( str$, unquoted:Int = False )
  183. Local length:Int
  184. Local i:Int
  185. If Not unquoted Then
  186. If str.length < 2 Or str[str.length - 1] <> Asc("~q") Then
  187. Err "Expecting expression but encountered malformed string literal"
  188. End If
  189. length = str.length - 1
  190. i = 1
  191. Else
  192. length = str.length
  193. End If
  194. Local sb:TStringBuffer = New TStringBuffer
  195. While i < length
  196. Local c:Int = str[i]
  197. i :+ 1
  198. If c <> Asc("~~") Then
  199. sb.AppendChar(c)
  200. Continue
  201. End If
  202. If i = length Err "Bad escape sequence in string"
  203. c = str[i]
  204. i :+ 1
  205. Select c
  206. Case Asc("~~")
  207. sb.AppendChar(c)
  208. Case Asc("0")
  209. sb.AppendChar(0)
  210. Case Asc("t")
  211. sb.AppendChar(Asc("~t"))
  212. Case Asc("r")
  213. sb.AppendChar(Asc("~r"))
  214. Case Asc("n")
  215. sb.AppendChar(Asc("~n"))
  216. Case Asc("q")
  217. sb.AppendChar(Asc("~q"))
  218. Case Asc("$") ' hex
  219. c = str[i]
  220. i :+ 1
  221. Local n:Int
  222. While True
  223. Local v:Int
  224. If c >= Asc("0") And c <= Asc("9") Then
  225. v = c-Asc("0")
  226. Else If c >= Asc("a") And c <= Asc("f") Then
  227. v = c-Asc("a")+10
  228. Else If c >= Asc("A") And c <= Asc("F") Then
  229. v = c-Asc("A")+10
  230. Else If c <> Asc("~~")
  231. Err "Bad escape sequence in string"
  232. Else
  233. Exit
  234. End If
  235. n = (n Shl 4) | (v & $f)
  236. If i = length Err "Bad escape sequence in string"
  237. c = str[i]
  238. i :+ 1
  239. Wend
  240. If c <> Asc("~~") Err "Bad escape sequence in string"
  241. sb.AppendChar(n)
  242. Case Asc("%") ' bin
  243. c = str[i]
  244. i :+ 1
  245. Local n:Int
  246. While c = Asc("1") Or c = Asc("0")
  247. n :Shl 1
  248. If c = Asc("1") Then
  249. n :| 1
  250. End If
  251. If i = length Err "Bad escape sequence in string"
  252. c = str[i]
  253. i :+ 1
  254. Wend
  255. If c <> Asc("~~") Err "Bad escape sequence in string"
  256. sb.AppendChar(n)
  257. Default
  258. If c >= Asc("1") And c <= Asc("9") Then
  259. Local n:Int
  260. While c >= Asc("0") And c <= Asc("9")
  261. n = n * 10 + (c-Asc("0"))
  262. If i = length Err "Bad escape sequence in string"
  263. c = str[i]
  264. i :+ 1
  265. Wend
  266. If c <> Asc("~~") Err "Bad escape sequence in string"
  267. sb.AppendChar(n)
  268. Else
  269. Err "Bad escape sequence in string"
  270. End If
  271. End Select
  272. Wend
  273. Return sb.ToString()
  274. End Function
  275. Function BmxProcessMultiString:String( str:String )
  276. Local valid:Int
  277. If str.length < 7 Then
  278. Err "Expecting expression but encountered malformed multiline string literal"
  279. End If
  280. For Local i:Int = 0 Until 3
  281. If str[i] <> Asc("~q") Or str[str.length -1 -i] <> Asc("~q") Then
  282. Err "Expecting expression but encountered malformed multiline string literal"
  283. End If
  284. Next
  285. str = str[3..str.length - 3]
  286. ' normalise line endings
  287. str = str.Replace("~r~n", "~n").Replace("~r", "~n")
  288. If str[0] <> Asc("~n") Then
  289. Err "Expecting EOL but encountered malformed multiline string literal"
  290. End If
  291. str = str[1..]
  292. Local LINES:String[] = str.Split("~n")
  293. Local lineCount:Int = LINES.length - 1
  294. Local last:String = LINES[lineCount]
  295. Local i:Int = last.length - 1
  296. While i >= 0
  297. If last[i] <> Asc(" ") And last[i] <> Asc("~t") Then
  298. Err "Expecting trailing whitespace"
  299. End If
  300. i :- 1
  301. Wend
  302. Local trailingIndent:String = last
  303. ' strip indent
  304. If trailingIndent Then
  305. For i = 0 Until lineCount
  306. Local line:String = LINES[i]
  307. If line.StartsWith(trailingIndent) Then
  308. line = line[trailingIndent.length..]
  309. LINES[i] = line
  310. End If
  311. Next
  312. End If
  313. ' right trim
  314. For i = 0 Until lineCount
  315. Local line:String = LINES[i]
  316. Local index:Int = line.length
  317. While index
  318. index :- 1
  319. If line[index] <> Asc(" ") And line[index] <> Asc("~t") Then
  320. Exit
  321. End If
  322. Wend
  323. If index < line.length - 1 Then
  324. line = line[..index + 1]
  325. LINES[i] = line
  326. End If
  327. Next
  328. Local sb:TStringBuffer = New TStringBuffer
  329. For i = 0 Until lineCount
  330. Local line:String = LINES[i]
  331. Local length:Int = line.length
  332. Local softWrap:Int
  333. If line And line[line.length-1] = Asc("\") Then
  334. softWrap = True
  335. length :- 1
  336. End If
  337. If line Then
  338. sb.Append(line[..length])
  339. End If
  340. If Not softWrap And i < lineCount - 1 Then
  341. sb.Append("~n")
  342. End If
  343. Next
  344. Return BmxUnquote(sb.ToString(), True)
  345. End Function
  346. Type TStack Extends TList
  347. Method Push(obj:Object)
  348. AddFirst(obj)
  349. End Method
  350. Method Length:Int()
  351. Return count()
  352. End Method
  353. Method Get:Object(index:Int)
  354. Return ValueAtIndex(index)
  355. End Method
  356. Method Pop:Object()
  357. Return RemoveFirst()
  358. End Method
  359. End Type
  360. Type TStringList Extends TList
  361. Method Join:String(s:String)
  362. Local arr:String[] = New String[count()]
  363. Local index:Int
  364. For Local t:String = EachIn Self
  365. arr[index] = t
  366. index :+ 1
  367. Next
  368. Return s.Join(arr)
  369. End Method
  370. End Type
  371. Type TKeyValue
  372. Field key:Object
  373. Field value:Object
  374. Method Create:TKeyValue(key:Object,value:Object)
  375. Self.key = key
  376. Self.value = value
  377. Return Self
  378. End Method
  379. Method Compare:Int(other:Object)
  380. If Not TKeyValue(other) Return 0
  381. Return key.Compare(TKeyValue(other).key)
  382. End Method
  383. End Type
  384. Type TUnorderedMap
  385. Field list:TList = New TList
  386. Field map:TMap = New TMap
  387. Field valuesList:TList = New TList
  388. Method Insert( key:Object,value:Object )
  389. list.AddLAst(New TKeyValue.Create(key, value))
  390. valuesList.AddLast(value)
  391. map.Insert(key, value)
  392. End Method
  393. Method Keys:TList()
  394. Local klist:TList = New TList
  395. For Local kv:TKeyValue = EachIn list
  396. klist.AddLast(kv.key)
  397. Next
  398. Return klist
  399. End Method
  400. Method Values:TList()
  401. 'Local vlist:TList = New TList
  402. 'For Local kv:TKeyValue = EachIn list
  403. ' vlist.AddLast(kv.value)
  404. 'Next
  405. Return valuesList
  406. End Method
  407. Method Contains:Int( key:Object )
  408. Return map.Contains(key)
  409. End Method
  410. Method ValueForKey:Object( key:Object )
  411. Return map.ValueForKey(key)
  412. End Method
  413. End Type
  414. Function MakeKeywords:String()
  415. Local keywords:String
  416. keywords :+ "import brl.classes~n"
  417. keywords :+ "Asc%(v$)=~qbrl_blitz_keywords_asc~q~n"
  418. keywords :+ "Chr$(v%)=~qbrl_blitz_keywords_chr~q~n"
  419. keywords :+ "Len%(v:Object)=~qbrl_blitz_keywords_len~q~n"
  420. keywords :+ "IncbinPtr@*(v$)=~qbbIncbinPtr~q~n"
  421. keywords :+ "IncbinLen%(v$)=~qbbIncbinLen~q~n"
  422. Return keywords
  423. End Function
  424. Function FilePath:String(path:String)
  425. Local baseDir:String = ExtractDir(path)
  426. Local bmxDir:String = baseDir + "/.bmx"
  427. If FileType(bmxDir) <> FILETYPE_DIR Then
  428. Throw "Missing : " + bmxDir
  429. End If
  430. Return bmxDir
  431. End Function
  432. Function BuildHeaderName:String(path:String)
  433. If opt_buildtype = BUILDTYPE_MODULE Then
  434. path = opt_modulename + "_" + StripDir(path)
  435. Else
  436. Local dir:String = ExtractDir(path).ToLower().Replace("/.bmx","")
  437. dir = dir[dir.findLast("/") + 1..]
  438. If dir.EndsWith(".mod") Then
  439. dir = dir.Replace(".mod", "")
  440. End If
  441. Local file:String = StripDir(path).ToLower()
  442. path = dir + "_" + file
  443. End If
  444. Return TStringHelper.Sanitize(path, , True)
  445. End Function
  446. Rem
  447. bbdoc: Get the header file name from a given module ident, optionally with include path.
  448. End Rem
  449. Function ModuleHeaderFromIdent:String(ident:String, includePath:Int = False)
  450. Local ns:String = ident[..ident.find(".")]
  451. Local name:String = ident[ident.find(".") + 1..]
  452. Local file:String = name + ".bmx" + FileMung() + ".h"
  453. If includePath Then
  454. file = ns + ".mod/" + name + ".mod/.bmx/" + file
  455. End If
  456. Return file
  457. End Function
  458. Function HeaderFile:String(path:String, mung:String)
  459. Local fileDir:String = FilePath(path)
  460. Local file:String = StripDir(path)
  461. Return fileDir + "/" + file + mung + ".h"
  462. End Function
  463. Function OutputFilePath:String(path:String, mung:String, suffix:String, bmxDir:Int = False)
  464. Local fileDir:String = FilePath(path)
  465. If bmxDir Then
  466. fileDir :+ "/.bmx"
  467. End If
  468. Local file:String = StripDir(path)
  469. Return fileDir + "/" + file + mung + "." + suffix
  470. End Function
  471. Function FileMung:String(makeApp:Int = False)
  472. Local m:String = "."
  473. If makeApp Then
  474. Select opt_apptype
  475. Case APPTYPE_CONSOLE
  476. m :+ "console."
  477. Case APPTYPE_GUI
  478. m :+ "gui."
  479. End Select
  480. End If
  481. If opt_release Then
  482. m :+ "release"
  483. Else
  484. m :+ "debug"
  485. End If
  486. If opt_coverage Then
  487. m :+ ".cov"
  488. End If
  489. ' If opt_threaded Then
  490. ' m :+ ".mt"
  491. ' End If
  492. m :+ "." + opt_platform
  493. m :+ "." + opt_arch
  494. Return m
  495. End Function
  496. Function HeaderComment:String()
  497. ' TODO
  498. End Function
  499. Global fileRegister:TMap = New TMap
  500. Function GenHash:String(file:String)
  501. Local Hash:String = bmx_gen_hash(file)
  502. If Not fileRegister.Contains(Hash) Then
  503. fileRegister.Insert(Hash, file)
  504. End If
  505. Return Hash
  506. End Function
  507. Type TTemplateRecord
  508. Field start:Int
  509. Field file:String
  510. Field source:String
  511. Method Create:TTemplateRecord(start:Int, file:String, source:String)
  512. Self.start = start
  513. Self.file = file
  514. Self.source = source
  515. Return Self
  516. End Method
  517. Method ToString:String()
  518. Local s:Byte Ptr = source.ToUTF8String()
  519. ?Not bmxng
  520. Local slen:Int = strlen_(s)
  521. ?bmxng
  522. Local slen:ULongInt = strlen_(s)
  523. ?
  524. ?Not bmxng
  525. Local dlen:Int = slen + 12
  526. ?bmxng
  527. Local dlen:ULongInt = slen + 12
  528. ?
  529. Local data:Byte[dlen]
  530. compress2(data, dlen, s, slen, 9)
  531. MemFree(s)
  532. Local t:String = "{" + start +","+ slen +","+ LangEnquote(file) + ","
  533. t :+ LangEnquote(TBase64.Encode(data, Int(dlen), 0, TBase64.DONT_BREAK_LINES))
  534. Return t + "}"
  535. End Method
  536. Function Load:TTemplateRecord(start:Int, file:String, size:Int, source:String)
  537. ?Not bmxng
  538. Local dlen:Int = size + 1
  539. ?bmxng
  540. Local dlen:ULongInt = size + 1
  541. ?
  542. Local data:Byte[dlen]
  543. Local s:Byte[] = TBase64.Decode(source)
  544. ?Not bmxng
  545. uncompress(data, dlen, s, s.length)
  546. ?bmxng
  547. uncompress(data, dlen, s, ULongInt(s.length))
  548. ?
  549. Return New TTemplateRecord.Create(start, file, String.FromUTF8String(data))
  550. End Function
  551. End Type
  552. Type TCallback
  553. Method Callback(obj:Object) Abstract
  554. End Type
  555. Type TFileHash
  556. Field statePtr:Byte Ptr
  557. Method Create:TFileHash()
  558. statePtr = bmx_hash_createState()
  559. Return Self
  560. End Method
  561. Method CalculateHash:String(stream:TStream)
  562. Const BUFFER_SIZE:Int = 8192
  563. bmx_hash_reset(statePtr)
  564. Local data:Byte[BUFFER_SIZE]
  565. While True
  566. Local read:Int = stream.Read(data, BUFFER_SIZE)
  567. bmx_hash_update(statePtr, data, read)
  568. If read < BUFFER_SIZE Then
  569. Exit
  570. End If
  571. Wend
  572. Return bmx_hash_digest(statePtr)
  573. End Method
  574. End Type
  575. Function CalculateFileHash:String(path:String)
  576. If Not _fileHasher Then
  577. _fileHasher = New TFileHash.Create()
  578. End If
  579. If FileType(path) = FILETYPE_FILE Then
  580. Local stream:TStream = ReadStream(path)
  581. Local fileHash:String = _fileHasher.CalculateHash(stream)
  582. stream.Close()
  583. Return fileHash
  584. End If
  585. Return Null
  586. End Function
  587. ?Not bmxng
  588. Const OP_MUL:Int = 0
  589. Const OP_DIV:Int = 1
  590. Const OP_MOD:Int = 2
  591. Const OP_SHL:Int = 3
  592. Const OP_SHR:Int = 4
  593. Const OP_SAR:Int = 5
  594. Const OP_ADD:Int = 6
  595. Const OP_SUB:Int = 7
  596. Const OP_AND:Int = 8
  597. Const OP_XOR:Int = 9
  598. Const OP_OR:Int = 10
  599. Function OpToInt:Int(op:String)
  600. Select op
  601. Case "*" Return OP_MUL
  602. Case "/" Return OP_DIV
  603. Case "mod" Return OP_MOD
  604. Case "shl" Return OP_SHL
  605. Case "shr" Return OP_SHR
  606. Case "sar" Return OP_SAR
  607. Case "+" Return OP_ADD
  608. Case "-" Return OP_SUB
  609. Case "&" Return OP_AND
  610. Case "~~" Return OP_XOR
  611. Case "|" Return OP_OR
  612. End Select
  613. InternalErr "TBinaryMathExpr.Eval.OpToInt : " + op
  614. End Function
  615. ?
  616. Extern
  617. Function strlen_:Int(s:Byte Ptr)="strlen"
  618. Function bmx_enum_next_power(char:Int, val:Long Var, ret:Long Var)
  619. Function bmx_gen_hash:String(txt:String)
  620. Function bmx_hash_createState:Byte Ptr()
  621. Function bmx_hash_reset(state:Byte Ptr)
  622. Function bmx_hash_update(state:Byte Ptr, data:Byte Ptr, length:Int)
  623. Function bmx_hash_digest:String(state:Byte Ptr)
  624. Function bmx_bitwise_not_uint:String(value:String)
  625. Function bmx_bitwise_not_sizet:String(value:String)
  626. Function bmx_bitwise_not_ulong:String(value:String)
  627. Function bmx_bitwise_not_longint:String(value:String, size:Int)
  628. Function bmx_bitwise_not_ulongint:String(value:String, size:Int)
  629. Function bmx_binarymathexpr_sizet:String(op:Int, lhs:String, rhs:String)
  630. Function bmx_binarymathexpr_uint:String(op:Int, lhs:String, rhs:String)
  631. Function bmx_binarymathexpr_ulong:String(op:Int, lhs:String, rhs:String)
  632. Function bmx_binarymathexpr_longint:String(op:Int, lhs:String, rhs:String, size:Int)
  633. Function bmx_binarymathexpr_ulongint:String(op:Int, lhs:String, rhs:String, size:Int)
  634. End Extern