Added assembler merging
This commit is contained in:
parent
92b7c22c61
commit
8549aedc60
6 changed files with 122 additions and 63 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue