Added assembler merging

This commit is contained in:
Eduard Urbach 2023-10-31 14:50:53 +01:00
parent 92b7c22c61
commit 8549aedc60
Signed by: eduard
GPG key ID: 49226B848C78F6C8
6 changed files with 122 additions and 63 deletions

View file

@ -60,16 +60,17 @@ func scanFile(path string, functions chan<- *Function) error {
tokens := token.Tokenize(contents)
var (
groupLevel = 0
blockLevel = 0
functionStart = -1
groupLevel = 0
blockLevel = 0
headerStart = -1
bodyStart = -1
)
for i, t := range tokens {
switch t.Kind {
case token.Identifier:
if blockLevel == 0 && groupLevel == 0 {
functionStart = i
headerStart = i
}
case token.GroupStart:
@ -81,12 +82,18 @@ func scanFile(path string, functions chan<- *Function) error {
case token.BlockStart:
blockLevel++
if blockLevel == 1 {
bodyStart = i
}
case token.BlockEnd:
blockLevel--
if blockLevel == 0 {
function := &Function{
Tokens: tokens[functionStart : i+1],
Name: tokens[headerStart].String(),
Head: tokens[headerStart:bodyStart],
Body: tokens[bodyStart : i+1],
}
functions <- function