Skip to content

Commit 75fa9dc

Browse files
authored
Merge pull request #368 from on-keyday/gen/fix-wasm-src2json
Gen/fix wasm src2json
2 parents 8b762a8 + 7595d61 commit 75fa9dc

390 files changed

Lines changed: 37280 additions & 35386 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@
1010
# supported CodeQL languages.
1111
#
1212
name: "CodeQL"
13-
1413
on:
1514
push:
1615
branches: ["main"]
1716
pull_request:
1817
branches: ["main"]
1918
schedule:
2019
- cron: "21 18 * * 0"
21-
2220
permissions:
2321
contents: read
24-
2522
jobs:
2623
analyze:
2724
name: Analyze
@@ -35,24 +32,21 @@ jobs:
3532
permissions:
3633
# required for all workflows
3734
security-events: write
38-
3935
# only required for workflows in private repositories
4036
actions: read
4137
contents: read
42-
4338
strategy:
4439
fail-fast: false
4540
matrix:
46-
language: ["c-cpp", "go"]
41+
language: ["c-cpp", "go", "actions"]
4742
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
4843
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
4944
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
5045
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
51-
5246
steps:
5347
- name: Checkout repository
5448
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
55-
49+
timeout-minutes: 5
5650
# Initializes the CodeQL tools for scanning.
5751

5852
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -75,30 +69,36 @@ jobs:
7569
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
7670
- name: Set up Ninja
7771
uses: seanmiddleditch/gha-setup-ninja@7e868db0f3406270dd46e1dac26c65f621456723 # master
72+
if: matrix.language != 'c-cpp'
73+
timeout-minutes: 5
7874
- name: Set up Clang
7975
uses: egor-tensin/setup-clang@8092a31dc33b0c41ee7cc5bb81fd0267490a0161 # v2.2
8076
if: matrix.language == 'c-cpp'
77+
timeout-minutes: 5
8178
with:
8279
version: latest
8380
platform: x64
8481
- name: Install libc++-dev and libc++abi-dev
82+
timeout-minutes: 5
8583
run: sudo apt-get install libc++-dev libc++abi-dev -y
8684
- name: Initialize CodeQL
8785
uses: github/codeql-action/init@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
86+
timeout-minutes: 5
8887
with:
8988
languages: ${{ matrix.language }}
9089
debug: true
9190
- name: Build C++ and Go
9291
if: matrix.language == 'c-cpp' || matrix.language == 'go'
92+
timeout-minutes: 5
9393
run: |
9494
env | grep -E "CODEQL|LD_PRELOAD|CC|CXX"
9595
export FUTILS_CXX_COMPILER=$CXX
9696
export FUTILS_C_COMPILER=$CC
9797
ldd $(which clang)
9898
FUTILS_DIR=./utils python build.py native
9999
./tool/src2json --version
100-
101100
- name: Perform CodeQL Analysis
102101
uses: github/codeql-action/analyze@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
102+
timeout-minutes: 5
103103
with:
104104
category: "/language:${{matrix.language}}"
Lines changed: 0 additions & 1 deletion
This file was deleted.

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@
178178
"name": "Debug ebm2cpp",
179179
"type": "cppvsdbg",
180180
"request": "launch",
181-
"program": "${workspaceRoot}/rebrgen/tool/ebmgen",
182-
"args": ["-i", "${workspaceRoot}/rebrgen/save/stream.bgn"],
181+
"program": "${workspaceRoot}/rebrgen/tool/ebm2c",
182+
"args": ["-i", "${workspaceRoot}/rebrgen/save/wasm.ebm"],
183183
"stopAtEntry": false,
184184
"cwd": "${workspaceRoot}/rebrgen",
185185
"environment": [],

astlib/ast2c/ast.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ struct ast2c_RawScope {
466466
size_t ident_size;
467467
void* owner;
468468
int branch_root;
469+
ast2c_Loc loc;
469470
};
470471

471472
struct ast2c_RawNode {
@@ -1520,6 +1521,7 @@ struct ast2c_Scope {
15201521
size_t ident_size;
15211522
ast2c_Node* owner;
15221523
int branch_root;
1524+
ast2c_Loc loc;
15231525
};
15241526

15251527
// returns 1 if succeed 0 if failed

astlib/ast2csharp/ast.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ public class Scope {
860860
public List<Ident>? Ident{get;set;}
861861
public Node? Owner{get;set;}
862862
public bool BranchRoot{get;set;}
863+
public Loc Loc{get;set;}
863864
}
864865
public struct Pos {
865866
public ulong Begin{get;set;}
@@ -883,6 +884,7 @@ public class RawScope {
883884
public List<ulong>? Ident{get;set;}
884885
public ulong? Owner{get;set;}
885886
public bool BranchRoot{get;set;}
887+
public Loc Loc{get;set;}
886888
}
887889
public class RawNode {
888890
public NodeType NodeType{get;set;}

astlib/ast2dart/lib/ast.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,7 @@ class Scope {
997997
List<Ident>? ident = [];
998998
Node? owner;
999999
bool branchRoot = false;
1000+
Loc loc = Loc();
10001001
factory Scope.fromJson(Map<String, dynamic> json) => _$ScopeFromJson(json);
10011002
}
10021003
@JsonSerializable()
@@ -1028,6 +1029,7 @@ class RawScope {
10281029
List<int> ident = [];
10291030
int? owner;
10301031
bool branchRoot = false;
1032+
Loc loc = Loc();
10311033
factory RawScope.fromJson(Map<String, dynamic> json) => _$RawScopeFromJson(json);
10321034
}
10331035
@JsonSerializable()

astlib/ast2go/ast/ast.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

astlib/ast2py/ast.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ class Scope:
729729
ident: List[Ident]
730730
owner: Optional[Node]
731731
branch_root: bool
732+
loc: Loc
732733

733734

734735
class Pos:
@@ -780,6 +781,7 @@ class RawScope:
780781
ident: List[int]
781782
owner: Optional[int]
782783
branch_root: bool
784+
loc: Loc
783785

784786
def parse_RawScope(json: dict) -> RawScope:
785787
ret = RawScope()
@@ -801,6 +803,7 @@ def parse_RawScope(json: dict) -> RawScope:
801803
else:
802804
ret.owner = None
803805
ret.branch_root = bool(json["branch_root"])
806+
ret.loc = parse_Loc(json["loc"])
804807
return ret
805808

806809

@@ -2371,6 +2374,7 @@ def ast2node(ast :JsonAst) -> Program:
23712374
if ast.scope[i].owner is not None:
23722375
scope[i].owner = ast.node[ast.scope[i].owner]
23732376
scope[i].branch_root = ast.scope[i].branch_root
2377+
scope[i].loc = ast.scope[i].loc
23742378
return node[0]
23752379

23762380
def walk(node: Node, f: Callable[[Callable,Node],None]) -> None:

astlib/ast2rust/core/src/ast.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9507,6 +9507,7 @@ pub struct Scope {
95079507
pub ident: Vec<Weak<RefCell<Ident>>>,
95089508
pub owner: Option<NodeWeak>,
95099509
pub branch_root: bool,
9510+
pub loc: Loc,
95109511
}
95119512

95129513
#[derive(Debug,Clone,Copy,Serialize,Deserialize)]
@@ -9538,6 +9539,7 @@ pub struct RawScope {
95389539
pub ident: Vec<usize>,
95399540
pub owner: Option<usize>,
95409541
pub branch_root: bool,
9542+
pub loc: Loc,
95419543
}
95429544

95439545
#[derive(Debug,Clone,Serialize,Deserialize)]
@@ -10325,6 +10327,7 @@ pub fn parse_ast(ast:JsonAst)->Result<Rc<RefCell<Program>> ,Error>{
1032510327
ident: Vec::new(),
1032610328
owner: None,
1032710329
branch_root: false,
10330+
loc: Loc{ pos: Pos{ begin: 0, end: 0 }, file: 0, line: 0, col: 0 },
1032810331
}));
1032910332
scopes.push(scope);
1033010333
}
@@ -15900,6 +15903,8 @@ pub fn parse_ast(ast:JsonAst)->Result<Rc<RefCell<Program>> ,Error>{
1590015903
};
1590115904
scope.borrow_mut().ident.push(Rc::downgrade(ident));
1590215905
}
15906+
scope.borrow_mut().branch_root = raw_scope.branch_root;
15907+
scope.borrow_mut().loc = raw_scope.loc;
1590315908
}
1590415909

1590515910
match nodes.get(0){

0 commit comments

Comments
 (0)