MCPcopy Create free account
hub / github.com/JayXon/Leanify / FunctionParser

Method FunctionParser

formats/lua.cpp:11–97  ·  view source on GitHub ↗

copied from an old code, need to refactor someday

Source from the content-addressed store, hash-verified

9
10// copied from an old code, need to refactor someday
11void Lua::FunctionParser()
12{
13
14 uint32_t i;
15 uint8_t *oldp;
16
17 // Function header
18 i = *(uint32_t *)p_read_;
19 p_read_ += i + 4;
20
21 // remove Source name, Line defined and last line defined
22 memset(p_write_, 0, 12);
23 *(uint32_t *)(p_write_ + 12) = *(uint32_t *)(p_read_ + 8);
24 p_write_ += 0x10;
25 p_read_ += 0xC;
26
27
28 // Instruction list
29 i = *(uint32_t *)p_read_ * 4 + 4;
30 memmove(p_write_, p_read_, i);
31 p_write_ += i;
32 p_read_ += i;
33
34
35 oldp = p_read_;
36 // Constant list
37 i = *(uint32_t *)p_read_;
38 p_read_ += 4;
39 while (i--)
40 {
41 switch (*p_read_++)
42 {
43 // 1=LUA_TBOOLEAN
44 case 1:
45 p_read_++;
46 break;
47 // 3=LUA_TNUMBER
48 case 3:
49 p_read_ += 8;
50 break;
51 // 4=LUA_TSTRING
52 case 4:
53 p_read_ += *(uint32_t *)p_read_ + 4;
54 }
55 }
56
57
58 // Function prototype list
59 i = *(uint32_t *)p_read_;
60 p_read_ += 4;
61
62 memmove(p_write_, oldp, p_read_ - oldp);
63 p_write_ += p_read_ - oldp;
64 while (i--)
65 {
66 FunctionParser();
67 }
68

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected