Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8ce7d62
Move show.py to c_analyzer_common.
ericsnowcurrently Sep 27, 2019
c40c247
Small cleanups around _check_results().
ericsnowcurrently Sep 27, 2019
bf3bd21
Merge c_parser.info into c_analyzer_common.info.
ericsnowcurrently Sep 27, 2019
52113ae
c_symbols.binary -> c_symbols.find.
ericsnowcurrently Sep 27, 2019
dc8333f
Add ID.match().
ericsnowcurrently Sep 30, 2019
9b47596
Add known.look_up_variable().
ericsnowcurrently Sep 30, 2019
67eea78
Add c_parser.find module.
ericsnowcurrently Sep 30, 2019
b61b704
Add c_symbols.find module.
ericsnowcurrently Sep 30, 2019
a041e4a
Avoid variable resolution in _nm.iter_symbols().
ericsnowcurrently Sep 30, 2019
b9b0499
Add c_analyzer_common.find module.
ericsnowcurrently Sep 30, 2019
15b60db
Use the new modules in __main__.
ericsnowcurrently Sep 30, 2019
2f9958f
Drop the old code.
ericsnowcurrently Sep 30, 2019
b05272c
Specify "preprocessed" option as an arg.
ericsnowcurrently Sep 30, 2019
80d299c
Add a TODO.
ericsnowcurrently Sep 30, 2019
15c1226
Use declarations.iter_all() instead of iter_variables().
ericsnowcurrently Sep 30, 2019
e08bad5
Make sure "resolve()" is used properly.
ericsnowcurrently Oct 1, 2019
fa6f1b5
Move extract_storage() to c_parser.declarations.
ericsnowcurrently Oct 4, 2019
6531014
Move the generic code under a top-level c_analyzer package.
ericsnowcurrently Oct 4, 2019
15f010b
Move some code to a new c_analyzer.variables package.
ericsnowcurrently Oct 4, 2019
c399dc0
c_global -> cpython.
ericsnowcurrently Oct 4, 2019
025e8c3
Do not use Variable in symbols or parser packages.
ericsnowcurrently Oct 15, 2019
f60551e
Drop "INCLUDES" from SOURCE_DIRS.
ericsnowcurrently Oct 18, 2019
4beba49
Process files more cleanly.
ericsnowcurrently Oct 18, 2019
9e5c09b
Fix a typo.
ericsnowcurrently Oct 18, 2019
6e14276
Call check_filename() properly.
ericsnowcurrently Oct 18, 2019
0ce0cd1
Fix one last import.
ericsnowcurrently Oct 18, 2019
264d698
Fix whitespace.
ericsnowcurrently Oct 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move the generic code under a top-level c_analyzer package.
  • Loading branch information
ericsnowcurrently committed Oct 4, 2019
commit 653101411c8cdcc294b038e606d6bcdd4f1e4cba
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_analyzer_common import SOURCE_DIRS, info
from c_analyzer_common.known import DATA_FILE as KNOWN_FILE
from c_analyzer.common import SOURCE_DIRS, info
from c_analyzer.common.known import DATA_FILE as KNOWN_FILE
import c_globals as cg
from c_globals.supported import IGNORED_FILE
from c_globals.__main__ import cmd_check, cmd_show, parse_args, main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_analyzer_common.info import ID, Variable
from c_analyzer.common.info import ID, Variable
from c_globals.supported import is_supported, ignored_from_file


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_analyzer_common.files import (
from c_analyzer.common.files import (
iter_files, _walk_tree, glob_tree,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_analyzer_common import info
from c_analyzer_common.find import vars_from_binary
from c_analyzer.common import info
from c_analyzer.common.find import vars_from_binary


class _Base(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ..util import PseudoStr, StrProxy, Object
from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_analyzer_common.info import (
from c_analyzer.common.info import (
UNKNOWN,
ID,
normalize_vartype, Variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_analyzer_common.info import ID, Variable
from c_analyzer_common.known import from_file
from c_analyzer.common.info import Variable
from c_analyzer.common.known import from_file


class FromFileTests(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_analyzer_common import info
from c_analyzer_common.show import basic
from c_analyzer.common import info
from c_analyzer.common.show import basic


TYPICAL = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_parser.declarations import (
from c_analyzer.parser.declarations import (
iter_global_declarations, iter_local_statements,
parse_func, _parse_var, parse_compound,
iter_variables,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..util import wrapped_arg_combos, StrProxy
from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_parser.preprocessor import (
from c_analyzer.parser.preprocessor import (
iter_lines,
# directives
parse_directive, PreprocessorDirective,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from ..util import PseudoStr, StrProxy, Object
from .. import tool_imports_for_tests
with tool_imports_for_tests():
from c_analyzer_common.info import ID
from c_symbols.info import Symbol
from c_analyzer.common.info import ID
from c_analyzer.symbols.info import Symbol


class SymbolTests(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
import sys


PKG_ROOT = os.path.dirname(__file__)
DATA_DIR = os.path.dirname(PKG_ROOT)
REPO_ROOT = os.path.dirname(
os.path.dirname(DATA_DIR))
TOOL_ROOT = (
os.path.dirname( # c-analyzer/
os.path.dirname( # c_analyzer/
os.path.dirname(__file__)))) # common/
DATA_DIR = TOOL_ROOT
REPO_ROOT = (
os.path.dirname( # ..
os.path.dirname(TOOL_ROOT))) # Tools/

SOURCE_DIRS = [os.path.join(REPO_ROOT, name) for name in [
'Include',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from c_analyzer_common import SOURCE_DIRS, PYTHON, files
from c_analyzer_common.info import UNKNOWN, Variable
from c_symbols import (
from ..common import SOURCE_DIRS, PYTHON, files
from ..common.info import UNKNOWN, Variable
from ..parser import (
find as p_find,
)
from ..symbols import (
info as s_info,
find as s_find,
)
from c_parser import (
find as p_find,
)

# XXX need tests:
# * vars_from_source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class Variable(_NTBase,
@classonly
def from_parts(cls, filename, funcname, name, decl, storage=None):
if storage is None:
from c_parser.declarations import extract_storage
from ..parser.declarations import extract_storage
storage = extract_storage(decl, infunc=funcname)
id = ID(filename, funcname, name)
self = cls(id, storage, decl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shlex
import subprocess

from c_analyzer_common.info import UNKNOWN
from ..common.info import UNKNOWN

from . import source

Expand Down Expand Up @@ -196,6 +196,27 @@ def parse_func(stmt, body):
return name, signature


#TYPE_SPEC = rf'''(?:
# )'''
#VAR_DECLARATOR = rf'''(?:
# )'''
#VAR_DECL = rf'''(?:
# {TYPE_SPEC}+
# {VAR_DECLARATOR}
# \s*
# )'''
#VAR_DECLARATION = rf'''(?:
# {VAR_DECL}
# (?: = [^=] [^;]* )?
# ;
# )'''
#
#
#def parse_variable(decl, *, inFunc=False):
# """Return [(name, storage, vartype)] for the given variable declaration."""
# ...


def _parse_var(stmt):
"""Return (name, vartype) for the given variable declaration."""
stmt = stmt.rstrip(';')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from c_analyzer_common.info import Variable, UNKNOWN
from ..common.info import Variable, UNKNOWN

from . import declarations

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

from c_analyzer_common.info import UNKNOWN, Variable
from ..common.info import UNKNOWN, Variable

from .preprocessor import _iter_clean_lines

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import re

from c_analyzer_common import util, info
from ..common import util, info


CONTINUATION = '\\' + os.linesep
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os.path
import shutil

from c_analyzer_common import util, info
from c_analyzer.common import util, info

from .info import Symbol

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import os.path
import shutil

from c_analyzer_common import PYTHON, known, files
from c_analyzer_common.info import UNKNOWN, Variable
from c_parser import find as p_find
from ..common import PYTHON, known, files
from ..common.info import UNKNOWN, Variable
from ..parser import find as p_find

from . import _nm
from .info import Symbol
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import namedtuple

from c_analyzer_common.info import ID
from c_analyzer_common.util import classonly, _NTBase
from c_analyzer.common.info import ID
from c_analyzer.common.util import classonly, _NTBase


class Symbol(_NTBase, namedtuple('Symbol', 'id kind external')):
Expand Down
9 changes: 5 additions & 4 deletions Tools/c-analyzer/c_globals/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import re
import sys

from c_analyzer_common import SOURCE_DIRS, REPO_ROOT, show
from c_analyzer_common.find import vars_from_binary
from c_analyzer_common.info import UNKNOWN
from c_analyzer_common.known import (
from c_analyzer.common import SOURCE_DIRS, REPO_ROOT, show
from c_analyzer.common.find import vars_from_binary
from c_analyzer.common.info import UNKNOWN
from c_analyzer.common.known import (
from_file as known_from_file,
DATA_FILE as KNOWN_FILE,
)

from .supported import is_supported, ignored_from_file, IGNORED_FILE, _is_object


Expand Down
14 changes: 9 additions & 5 deletions Tools/c-analyzer/c_globals/supported.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import os.path
import re

from c_analyzer_common import DATA_DIR
from c_analyzer_common.info import ID
from c_analyzer_common.util import read_tsv, write_tsv
from c_analyzer.common import DATA_DIR
from c_analyzer.common.info import ID
from c_analyzer.common.util import read_tsv, write_tsv

# XXX need tests:
# * generate / script


IGNORED_FILE = os.path.join(DATA_DIR, 'ignored.tsv')
Expand Down Expand Up @@ -379,11 +382,12 @@ def _generate_ignored_file(variables, filename=None, *,


if __name__ == '__main__':
from c_analyzer_common import SOURCE_DIRS
from c_analyzer_common.known import (
from c_analyzer.common import SOURCE_DIRS
from c_analyzer.common.known import (
from_file as known_from_file,
DATA_FILE as KNOWN_FILE,
)
# XXX This is wrong!
from . import find
known = known_from_file(KNOWN_FILE)
knownvars = (known or {}).get('variables')
Expand Down