Metadata-Version: 2.1
Name: move-fcg-tool
Version: 0.1.0
Summary: Move Function Call Graph (FCG) extraction tool using tree-sitter (supports Aptos Move and Sui Move)
Home-page: https://github.com/movebit/aptos-move-analyzer
Author: RISK_Python_Backend Team
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Compilers
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# move-fcg-tool

[![Build Status](https://img.shields.io/badge/build-passing-brightgreen)](https://github.com/movebit/aptos-move-analyzer)
[![Python](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)

Move Function Call Graph (FCG) extraction tool using tree-sitter - **Universal support for Aptos Move and Sui Move**

## ✨ Features

- ✅ **Universal Move Support**: Parses both Aptos Move and Sui Move
- ✅ **Complete Syntax Coverage**: Modules, structs, functions, generics, abilities
- ✅ **Advanced Features**: Phantom types, entry functions, shared objects, dynamic fields
- ✅ **Function Call Graph (FCG)**: Extract function definitions and call relationships
- ✅ **Cross-Platform**: Windows, Linux, macOS (Intel & Apple Silicon)
- ✅ **Python Bindings**: Easy integration with Python projects
- ✅ **Type Stubs**: Full type hints support

## 📦 Installation

### From PyPI (when published)

```bash
pip install move-fcg-tool
```

### From Wheel (local)

```bash
# Windows
pip install move_fcg_tool-0.1.0-cp312-cp312-win_amd64.whl

# Linux
pip install move_fcg_tool-0.1.0-cp310-cp310-linux_x86_64.whl

# macOS
pip install move_fcg_tool-0.1.0-cp314-cp314-macosx_15_0_x86_64.whl
```

## 🚀 Quick Start

```python
import tree_sitter
from tree_sitter_move import language

# Create parser
parser = tree_sitter.Parser(tree_sitter.Language(language()))

# Parse Move code
code = b'''
module 0x1::example {
    struct Counter has key {
        value: u64
    }

    public fun increment(counter: &mut Counter) {
        counter.value = counter.value + 1;
    }
}
'''

tree = parser.parse(code)
print(tree.root_node.sexp())
```

## 📚 Supported Move Variants

### Aptos Move

```move
module 0x1::coin {
    use std::signer;

    struct Coin has key {
        balance: u64
    }

    public fun mint(account: &signer, value: u64) {
        move_to(account, Coin { balance: value });
    }

    public fun get_balance(addr: address): u64 acquires Coin {
        borrow_global<Coin>(addr).balance
    }
}
```

**Aptos-specific features:**
- Global storage operators: `move_to`, `borrow_global`, `borrow_global_mut`, `exists`
- `acquires` keyword
- `signer` type for authentication

### Sui Move

```move
module 0x2::coin {
    use sui::object::{Self, UID};
    use sui::transfer;
    use sui::tx_context::{Self, TxContext};

    struct Coin<phantom T> has key, store {
        id: UID,
        balance: u64
    }

    public entry fun mint<T>(value: u64, ctx: &mut TxContext) {
        let coin = Coin {
            id: object::new(ctx),
            balance: value
        };
        transfer::transfer(coin, tx_context::sender(ctx));
    }

    public fun merge<T>(coin1: &mut Coin<T>, coin2: Coin<T>) {
        let Coin { id, balance } = coin2;
        object::delete(id);
        coin1.balance = coin1.balance + balance;
    }
}
```

**Sui-specific features:**
- Object model with `UID`
- `phantom` type parameters
- `entry` functions
- `transfer::transfer`, `transfer::share_object`
- `TxContext` for transaction context

## 🔧 Building from Source

### Windows

**Requirements:**
- Python 3.8+
- MinGW-w64 or MSVC

```bash
# Using MinGW
python setup.py build_ext --inplace --compiler=mingw32
python setup.py bdist_wheel

# Using MSVC
python setup.py build_ext --inplace
python setup.py bdist_wheel
```

### Linux / WSL

**Requirements:**
- Python 3.8+
- GCC

```bash
chmod +x build_linux.sh
./build_linux.sh
```

Or manually:
```bash
sudo apt-get install -y build-essential python3-dev
python3 setup.py build_ext --inplace
python3 setup.py bdist_wheel
```

### macOS

**Requirements:**
- Python 3.8+
- Xcode Command Line Tools

```bash
chmod +x build_macos.sh
./build_macos.sh
```

Or manually:
```bash
xcode-select --install
python3 setup.py build_ext --inplace
python3 setup.py bdist_wheel
```

**详细说明**: 请参考 [BUILD_MACOS.md](BUILD_MACOS.md)

## 🧪 Testing

```bash
# Test Sui Move advanced features
python test_sui_advanced.py

# Expected output:
# ✅ PASS: Shared Objects
# ✅ PASS: Entry Functions
# ✅ PASS: Phantom Types
# ✅ PASS: Witness Pattern
# ✅ PASS: Dynamic Fields
# 总计: 5/5 通过
```

## 📖 Grammar Source

This package is based on the Move grammar from [aptos-move-analyzer](https://github.com/movebit/aptos-move-analyzer), which provides comprehensive support for the Move language syntax.

**Why it works for both Aptos and Sui:**
- Aptos Move and Sui Move share the same core syntax
- Differences are primarily in semantics (libraries, object model)
- The tree-sitter grammar parses syntax, not semantics

## 📄 License

Apache-2.0

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## 📞 Support

If you encounter any issues:
1. Check the [BUILD_MACOS.md](BUILD_MACOS.md) for platform-specific guidance
2. Run the test suite: `python test_sui_advanced.py`
3. Open an issue with your error logs



