<commit_before>// Copyright 2010 The GoGo Authors. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package main

import "./libgogo/_obj/libgogo"

var InSymTable uint64 = 0;

func GetLine() string {
    var line string;
    var singleChar byte;
    for singleChar = GetCharWrapped(); (singleChar != 0) && (singleChar != 10); singleChar = GetCharWrapped() {
        libgogo.CharAppend(&line, singleChar);
    }
    if singleChar == 0 {
        tok.id = TOKEN_EOS;
    }
    return line;
}

func GetNextSymToken(lineRest string, offset *uint64) string {
    var symtoken string;
    var i uint64;
    var len uint64;
    len = libgogo.StringLength(lineRest);
    for i = *offset; (i < len) && (lineRest[i] != ','); i=i+1 {
        if (lineRest[i] != '/') && (lineRest[i] != ' ') {
            libgogo.CharAppend(&symtoken, lineRest[i]);
        }
    }
    *offset = i+1;
    return symtoken;
}

func ParseLine(line string) {
    // Something like 
    // Type, Ndx, Name, Ret, Params [,...]
    // FUNC ,UND    ,test·test      ,           ,uint64
    var offset uint64 = 0;
    var symtoken string;
    symtoken = GetNextSymToken(line,&offset);
    libgogo.PrintString("Type: ");
    libgogo.PrintString(symtoken);
    libgogo.PrintString("\n");

    symtoken = GetNextSymToken(line,&offset);
    libgogo.PrintString("Defined: ");
    libgogo.PrintString(symtoken);
    libgogo.PrintString("\n");

    symtoken = GetNextSymToken(line,&offset);
    libgogo.PrintString("Packagename+Var-/Functionname: ");
    libgogo.PrintString(symtoken);
    libgogo.PrintString("\n");

    symtoken = GetNextSymToken(line,&offset);
    libgogo.PrintString("Return, vartype: ");
    libgogo.PrintString(symtoken);
    libgogo.PrintString("\n");

}

func Link() {
    var line string;
    var strCmp uint64;

    tok.id = 0;
    tok.nextChar = 0;
    tok.nextToken = 0;   
    tok.llCnt = 0; 
    
    for line = GetLine(); tok.id != TOKEN_EOS ;line = GetLine() {
        strCmp = libgogo.StringCompare("// ##START_SYM_TABLE", line)
        if (strCmp == 0) {
            libgogo.PrintString("Symboltable start\n");
            InSymTable = 1;
            line = GetLine();
        } 
        strCmp = libgogo.StringCompare("// ##END_SYM_TABLE", line)
        if (strCmp == 0) {
            libgogo.PrintString("Symboltable end\n");
            InSymTable = 0;
        }
        if InSymTable != 0 {
            ParseLine(line);
            libgogo.PrintString("\n");
        }        
    }
}<commit_msg>linker.go: Syntax fixes (despite the one that cannot be fixed as direct dereferring of pointers is not supported)<commit_after>// Copyright 2010 The GoGo Authors. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.

package main

import "./libgogo/_obj/libgogo"

var InSymTable uint64 = 0;

func GetLine() string {
    var line string;
    var singleChar byte;
    for singleChar = GetCharWrapped(); (singleChar != 0) && (singleChar != 10); singleChar = GetCharWrapped() {
        libgogo.CharAppend(&line, singleChar);
    }
    if singleChar == 0 {
        tok.id = TOKEN_EOS;
    }
    return line;
}

func GetNextSymToken(lineRest string, offset *uint64) string {
    var symtoken string;
    var i uint64;
    var len uint64;
    len = libgogo.StringLength(lineRest);
    for i = *offset; (i < len) && (lineRest[i] != ','); i=i+1 {
        if (lineRest[i] != '/') && (lineRest[i] != ' ') {
            libgogo.CharAppend(&symtoken, lineRest[i]);
        }
    }
    *offset = i+1;
    return symtoken;
}

func ParseLine(line string) {
    // Something like 
    // Type, Ndx, Name, Ret, Params [,...]
    // FUNC ,UND    ,test·test      ,           ,uint64
    var offset uint64 = 0;
    var symtoken string;
    symtoken = GetNextSymToken(line,&offset);
    libgogo.PrintString("Type: ");
    libgogo.PrintString(symtoken);
    libgogo.PrintString("\n");

    symtoken = GetNextSymToken(line,&offset);
    libgogo.PrintString("Defined: ");
    libgogo.PrintString(symtoken);
    libgogo.PrintString("\n");

    symtoken = GetNextSymToken(line,&offset);
    libgogo.PrintString("Packagename+Var-/Functionname: ");
    libgogo.PrintString(symtoken);
    libgogo.PrintString("\n");

    symtoken = GetNextSymToken(line,&offset);
    libgogo.PrintString("Return, vartype: ");
    libgogo.PrintString(symtoken);
    libgogo.PrintString("\n");

}

func Link() {
    var line string;
    var strCmp uint64;

    tok.id = 0;
    tok.nextChar = 0;
    tok.nextToken = 0;   
    tok.llCnt = 0; 
    
    for line = GetLine(); tok.id != TOKEN_EOS ;line = GetLine() {
        strCmp = libgogo.StringCompare("// ##START_SYM_TABLE", line);
        if (strCmp == 0) {
            libgogo.PrintString("Symboltable start\n");
            InSymTable = 1;
            line = GetLine();
        } 
        strCmp = libgogo.StringCompare("// ##END_SYM_TABLE", line);
        if (strCmp == 0) {
            libgogo.PrintString("Symboltable end\n");
            InSymTable = 0;
        }
        if InSymTable != 0 {
            ParseLine(line);
            libgogo.PrintString("\n");
        }        
    }
}
{'fraction_non_alphanumeric': 0.13864419762543087, 'fraction_numerical': 0.013404825737265416, 'mean_word_length': 2.4658261446582617, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1299695', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1729, 'n_words': 398}