Skip to content

Commit acfd84a

Browse files
authored
Sync internal updates on Apr 2 (#46)
1 parent 5d2377b commit acfd84a

208 files changed

Lines changed: 11993 additions & 7444 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.

MODULE.bazel

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ bazel_dep(name = "nlohmann_json", version = "3.11.3")
2222
bazel_dep(name = "googletest", version = "1.15.0")
2323

2424
# https://registry.bazel.build/modules/protobuf
25-
bazel_dep(name = "protobuf", version = "31.1",
26-
repo_name = "com_google_protobuf")
25+
bazel_dep(
26+
name = "protobuf",
27+
version = "31.1",
28+
repo_name = "com_google_protobuf",
29+
)
2730

2831
# https://registry.bazel.build/modules/re2
2932
bazel_dep(name = "re2", version = "2024-07-02")

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ JSIR needs to achieve two seemingly conflicting goals:
3838
* It needs to be **low-level** enough to facilitate dataflow analysis, in
3939
order to support taint analysis, constant propagation, etc..
4040

41-
To achieve these goals, JSIR defines a high level IR that uses MLIR regions to accurately model control flow structures.
41+
To achieve these goals, JSIR defines a high level IR that uses MLIR regions to
42+
accurately model control flow structures.
4243

4344
See
4445
[intermediate_representation_design.md](docs/intermediate_representation_design.md)
@@ -61,7 +62,6 @@ docker run --rm jsir:latest jsir_gen --help
6162
docker run --rm -v $(pwd):/workspace jsir:latest jsir_gen --input_file=/workspace/yourfile.js
6263
```
6364

64-
6565
### Install build tools
6666

6767
We have only tested `clang` on Linux:

maldoca/astgen/BUILD

Lines changed: 192 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,35 +70,218 @@ cc_library(
7070
)
7171

7272
cc_library(
73-
name = "ast_gen",
74-
srcs = ["ast_gen.cc"],
75-
hdrs = ["ast_gen.h"],
73+
name = "printer_base",
74+
hdrs = ["printer_base.h"],
75+
deps = [
76+
"@com_google_protobuf//src/google/protobuf/io",
77+
"@com_google_protobuf//src/google/protobuf/io:printer",
78+
],
79+
)
80+
81+
cc_library(
82+
name = "ast_gen_utils",
83+
hdrs = ["ast_gen_utils.h"],
84+
deps = [
85+
":ast_def",
86+
"//maldoca/base:path",
87+
"@abseil-cpp//absl/algorithm:container",
88+
"@abseil-cpp//absl/strings",
89+
"@com_google_protobuf//src/google/protobuf/io:printer",
90+
],
91+
)
92+
93+
cc_library(
94+
name = "cc_printer_base",
95+
srcs = ["cc_printer_base.cc"],
96+
hdrs = ["cc_printer_base.h"],
97+
deps = [
98+
":ast_def",
99+
":ast_gen_utils",
100+
":printer_base",
101+
"@abseil-cpp//absl/strings",
102+
"@com_google_protobuf//src/google/protobuf/io",
103+
],
104+
)
105+
106+
cc_library(
107+
name = "ast_header_printer",
108+
srcs = ["ast_header_printer.cc"],
109+
hdrs = ["ast_header_printer.h"],
110+
deps = [
111+
":ast_def",
112+
":ast_gen_utils",
113+
":cc_printer_base",
114+
":symbol",
115+
"@abseil-cpp//absl/strings",
116+
"@com_google_protobuf//src/google/protobuf/io",
117+
],
118+
)
119+
120+
cc_library(
121+
name = "ast_source_printer",
122+
srcs = ["ast_source_printer.cc"],
123+
hdrs = ["ast_source_printer.h"],
76124
deps = [
77125
":ast_def",
78126
":ast_def_cc_proto",
127+
":ast_gen_utils",
128+
":cc_printer_base",
129+
":symbol",
130+
"@abseil-cpp//absl/strings",
131+
"@abseil-cpp//absl/strings:str_format",
132+
"@com_google_protobuf//src/google/protobuf/io",
133+
],
134+
)
135+
136+
cc_library(
137+
name = "ast_serialize_printer",
138+
srcs = ["ast_serialize_printer.cc"],
139+
hdrs = ["ast_serialize_printer.h"],
140+
deps = [
141+
":ast_def",
142+
":ast_gen_utils",
143+
":cc_printer_base",
144+
":symbol",
145+
"@abseil-cpp//absl/log",
146+
"@abseil-cpp//absl/log:check",
147+
"@abseil-cpp//absl/strings",
148+
"@abseil-cpp//absl/strings:str_format",
149+
"@com_google_protobuf//src/google/protobuf/io",
150+
],
151+
)
152+
153+
cc_library(
154+
name = "ast_from_json_printer",
155+
srcs = ["ast_from_json_printer.cc"],
156+
hdrs = ["ast_from_json_printer.h"],
157+
deps = [
158+
":ast_def",
159+
":ast_def_cc_proto",
160+
":ast_from_json_utils",
161+
":ast_gen_utils",
162+
":cc_printer_base",
79163
":symbol",
80-
"//maldoca/base:path",
81164
"@abseil-cpp//absl/algorithm:container",
82165
"@abseil-cpp//absl/base:core_headers",
83166
"@abseil-cpp//absl/cleanup",
84-
"@abseil-cpp//absl/container:btree",
85167
"@abseil-cpp//absl/container:flat_hash_set",
86168
"@abseil-cpp//absl/log",
87169
"@abseil-cpp//absl/log:check",
88170
"@abseil-cpp//absl/strings",
171+
"@com_google_protobuf//src/google/protobuf/io",
172+
],
173+
)
174+
175+
cc_library(
176+
name = "ts_interface_printer",
177+
srcs = ["ts_interface_printer.cc"],
178+
hdrs = ["ts_interface_printer.h"],
179+
deps = [
180+
":ast_def",
181+
":ast_def_cc_proto",
182+
":ast_gen_utils",
183+
":printer_base",
184+
"@abseil-cpp//absl/strings",
185+
"@com_google_protobuf//src/google/protobuf/io",
186+
],
187+
)
188+
189+
cc_library(
190+
name = "ir_table_gen_printer",
191+
srcs = ["ir_table_gen_printer.cc"],
192+
hdrs = ["ir_table_gen_printer.h"],
193+
deps = [
194+
":ast_def",
195+
":ast_gen_utils",
196+
":cc_printer_base",
197+
":symbol",
198+
"@abseil-cpp//absl/algorithm:container",
199+
"@abseil-cpp//absl/log",
200+
"@abseil-cpp//absl/strings",
201+
"@com_google_protobuf//src/google/protobuf/io",
202+
],
203+
)
204+
205+
cc_library(
206+
name = "ast_to_ir_source_printer",
207+
srcs = ["ast_to_ir_source_printer.cc"],
208+
hdrs = ["ast_to_ir_source_printer.h"],
209+
deps = [
210+
":ast_def",
211+
":ast_def_cc_proto",
212+
":ast_gen_utils",
213+
":cc_printer_base",
214+
":symbol",
215+
"@abseil-cpp//absl/algorithm:container",
216+
"@abseil-cpp//absl/base:core_headers",
217+
"@abseil-cpp//absl/log",
218+
"@abseil-cpp//absl/log:check",
219+
"@abseil-cpp//absl/strings",
89220
"@abseil-cpp//absl/strings:str_format",
90221
"@com_google_protobuf//src/google/protobuf/io",
222+
],
223+
)
224+
225+
cc_library(
226+
name = "ir_to_ast_source_printer",
227+
srcs = ["ir_to_ast_source_printer.cc"],
228+
hdrs = ["ir_to_ast_source_printer.h"],
229+
deps = [
230+
":ast_def",
231+
":ast_def_cc_proto",
232+
":ast_gen_utils",
233+
":cc_printer_base",
234+
":printer_base",
235+
":symbol",
236+
"@abseil-cpp//absl/base:core_headers",
237+
"@abseil-cpp//absl/container:btree",
238+
"@abseil-cpp//absl/log",
239+
"@abseil-cpp//absl/log:check",
240+
"@abseil-cpp//absl/strings",
241+
"@com_google_protobuf//src/google/protobuf/io",
91242
"@com_google_protobuf//src/google/protobuf/io:printer",
92243
],
93244
)
94245

246+
cc_library(
247+
name = "ast_from_json_utils",
248+
hdrs = ["ast_from_json_utils.h"],
249+
deps = [
250+
"//maldoca/base:status",
251+
"@abseil-cpp//absl/functional:any_invocable",
252+
"@abseil-cpp//absl/status",
253+
"@abseil-cpp//absl/status:statusor",
254+
"@abseil-cpp//absl/strings",
255+
"@nlohmann_json//:json",
256+
],
257+
)
258+
259+
cc_library(
260+
name = "ir_to_ast_util",
261+
hdrs = ["ir_to_ast_util.h"],
262+
deps = [
263+
"//maldoca/base:status",
264+
"@abseil-cpp//absl/status",
265+
"@abseil-cpp//absl/status:statusor",
266+
"@abseil-cpp//absl/strings:string_view",
267+
"@llvm-project//llvm:Support",
268+
"@llvm-project//mlir:IR",
269+
],
270+
)
271+
95272
cc_binary(
96273
name = "ast_gen_main",
97274
srcs = ["ast_gen_main.cc"],
98275
deps = [
99276
":ast_def",
100277
":ast_def_cc_proto",
101-
":ast_gen",
278+
":ast_from_json_printer",
279+
":ast_header_printer",
280+
":ast_serialize_printer",
281+
":ast_source_printer",
282+
":ast_to_ir_source_printer",
283+
":ir_table_gen_printer",
284+
":ir_to_ast_source_printer",
102285
"//maldoca/base:filesystem",
103286
"//maldoca/base:path",
104287
"//maldoca/base:status",
@@ -113,8 +296,10 @@ cc_test(
113296
deps = [
114297
":ast_def",
115298
":ast_def_cc_proto",
116-
":ast_gen",
299+
":ast_from_json_printer",
300+
":ast_header_printer",
117301
":symbol",
302+
":ts_interface_printer",
118303
"//maldoca/base:filesystem",
119304
"//maldoca/base/testing:status_matchers",
120305
"@abseil-cpp//absl/memory",

0 commit comments

Comments
 (0)