-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
183 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
///////////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// chibicc-toolchain - The specialized backend toolchain for chibicc-cil | ||
// Copyright (c) Kouji Matsui(@kozy_kekyo, @kekyo @mastodon.cloud) | ||
// | ||
// Licensed under MIT: https://opensource.org/licenses/MIT | ||
// | ||
///////////////////////////////////////////////////////////////////////////////////// | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using chibicc.common.Tokenizing; | ||
|
||
namespace chibicc.common.Archiving; | ||
|
||
public static class ArchiverUtilities | ||
{ | ||
public static readonly string SymbolTableFileName = "__symtable$"; | ||
|
||
public static IEnumerable<Symbol> EnumerateSymbols(TextReader tr, string fileName) | ||
{ | ||
var tokenizer = new Tokenizer(); | ||
|
||
while (true) | ||
{ | ||
var line = tr.ReadLine(); | ||
if (line == null) | ||
{ | ||
break; | ||
} | ||
|
||
var tokens = tokenizer.TokenizeLine(line); | ||
if (tokens.Length >= 3) | ||
{ | ||
var directive = tokens[0]; | ||
var scope = tokens[1]; | ||
if (directive.Type == TokenTypes.Directive && | ||
scope.Type == TokenTypes.Identity && | ||
scope.Text is "public" or "internal") | ||
{ | ||
switch (directive.Text) | ||
{ | ||
case "function": | ||
case "global": | ||
case "enumeration": | ||
if (tokens.Length >= 4) | ||
{ | ||
yield return new(directive, scope, tokens[3], fileName); | ||
} | ||
break; | ||
case "structure": | ||
yield return new(directive, scope, tokens[2], fileName); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
///////////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// chibicc-toolchain - The specialized backend toolchain for chibicc-cil | ||
// Copyright (c) Kouji Matsui(@kozy_kekyo, @kekyo @mastodon.cloud) | ||
// | ||
// Licensed under MIT: https://opensource.org/licenses/MIT | ||
// | ||
///////////////////////////////////////////////////////////////////////////////////// | ||
|
||
using chibicc.common.Tokenizing; | ||
|
||
namespace chibicc.common.Archiving; | ||
|
||
public readonly struct Symbol | ||
{ | ||
public readonly Token Directive; | ||
public readonly Token Scope; | ||
public readonly Token Name; | ||
public readonly string FileName; | ||
|
||
public Symbol(Token directive, Token scope, Token name, string fileName) | ||
{ | ||
this.Directive = directive; | ||
this.Scope = scope; | ||
this.Name = name; | ||
this.FileName = fileName; | ||
} | ||
} |
Oops, something went wrong.