@@ -31,6 +31,7 @@ def standalone_compile(
31
31
working_dir : Optional [str ] = None ,
32
32
remappings : Optional [List [str ]] = None ,
33
33
evm_version : Optional [str ] = None ,
34
+ via_ir : Optional [bool ] = None ,
34
35
) -> None :
35
36
"""
36
37
Boilerplate function to run the the standardjson. compilation_unit.compiler_version must be set before calling this function
@@ -48,6 +49,7 @@ def standalone_compile(
48
49
working_dir (Optional[str]): working directory
49
50
remappings (Optional[List[str]]): list of solc remaps to use
50
51
evm_version (Optional[str]): EVM version to target. None for default
52
+ via_ir (Optional[bool]): whether to enable the viaIR compilation flag. None for unset
51
53
52
54
Returns:
53
55
@@ -70,6 +72,9 @@ def standalone_compile(
70
72
if evm_version is not None :
71
73
add_evm_version (standard_json_dict , evm_version )
72
74
75
+ if via_ir is not None :
76
+ add_via_ir (standard_json_dict , via_ir )
77
+
73
78
add_optimization (
74
79
standard_json_dict ,
75
80
compilation_unit .compiler_version .optimized ,
@@ -278,6 +283,20 @@ def add_evm_version(json_dict: Dict, version: str) -> None:
278
283
json_dict ["settings" ]["evmVersion" ] = version
279
284
280
285
286
+ def add_via_ir (json_dict : Dict , enabled : bool ) -> None :
287
+ """
288
+ Enable or disable the "viaIR" compilation flag.
289
+
290
+ Args:
291
+ json_dict (Dict): solc standard json input
292
+ enabled (bool): whether viaIR is enabled
293
+
294
+ Returns:
295
+
296
+ """
297
+ json_dict ["settings" ]["viaIR" ] = enabled
298
+
299
+
281
300
def parse_standard_json_output (
282
301
targets_json : Dict , compilation_unit : CompilationUnit , solc_working_dir : Optional [str ] = None
283
302
) -> None :
0 commit comments