Remove debug printing functionality from WASM codegen.
PiperOrigin-RevId: 828545426 Change-Id: I136e6290c7ffdd4c2029aaf72cb90e0fc3cc7a9f
This commit is contained in:
committed by
Copybara-Service
parent
01b0ea5b7d
commit
ff0ae09bc4
@@ -78,12 +78,6 @@ def try_cast_to_scalar_type(value: str) -> int | float | str:
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def debug_print(msg: str):
|
|
||||||
"""Prints a message to the console if STRUCT_DEBUG_MODE is enabled."""
|
|
||||||
if constants.STRUCT_DEBUG_MODE:
|
|
||||||
print(msg)
|
|
||||||
|
|
||||||
|
|
||||||
def replace_lines_containing_marker(
|
def replace_lines_containing_marker(
|
||||||
lines: list[str],
|
lines: list[str],
|
||||||
marker_to_replace: str,
|
marker_to_replace: str,
|
||||||
|
|||||||
@@ -462,11 +462,6 @@ BYTE_FIELDS: Dict[str, Dict[str, str]] = {
|
|||||||
"arena": {"size": "narena"},
|
"arena": {"size": "narena"},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Boolean flag to enable debug prints during the struct wrapper and binding
|
|
||||||
# generation process. When set to `True`, it will print additional information
|
|
||||||
# about the steps being executed.
|
|
||||||
STRUCT_DEBUG_MODE: bool = False
|
|
||||||
|
|
||||||
# These structs require specific function calls for creation and/or deletion,
|
# These structs require specific function calls for creation and/or deletion,
|
||||||
# or some of their fields need to be handled manually for now;
|
# or some of their fields need to be handled manually for now;
|
||||||
# making their wrapper constructors/destructors non-trivial.
|
# making their wrapper constructors/destructors non-trivial.
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ from wasm.codegen.helpers import common
|
|||||||
from wasm.codegen.helpers import constants
|
from wasm.codegen.helpers import constants
|
||||||
|
|
||||||
|
|
||||||
debug_print = common.debug_print
|
|
||||||
|
|
||||||
introspect_structs = structs.STRUCTS
|
introspect_structs = structs.STRUCTS
|
||||||
|
|
||||||
|
|
||||||
@@ -269,9 +267,6 @@ class StructFieldHandler:
|
|||||||
inner_type_name.startswith("mj")
|
inner_type_name.startswith("mj")
|
||||||
and inner_type_name not in constants.PRIMITIVE_TYPES
|
and inner_type_name not in constants.PRIMITIVE_TYPES
|
||||||
):
|
):
|
||||||
debug_print(
|
|
||||||
f"\tcomplex pointer type: needs manual wrapper: {self.field.name}"
|
|
||||||
)
|
|
||||||
# it's a pointer to a single struct,
|
# it's a pointer to a single struct,
|
||||||
# like the `element` field in mjs structs
|
# like the `element` field in mjs structs
|
||||||
# and the struct is not manually added
|
# and the struct is not manually added
|
||||||
@@ -296,10 +291,6 @@ class StructFieldHandler:
|
|||||||
initialization=f", {self.field.name}(ptr_->{self.field.name})",
|
initialization=f", {self.field.name}(ptr_->{self.field.name})",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
debug_print(
|
|
||||||
"\tcomplex pointer type with array extent: needs manual wrapper:"
|
|
||||||
f" {self.field.name}"
|
|
||||||
)
|
|
||||||
return self._get_manual_definition(comment_type="complex pointer field")
|
return self._get_manual_definition(comment_type="complex pointer field")
|
||||||
|
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
@@ -342,10 +333,8 @@ class StructFieldHandler:
|
|||||||
elif inner_type.name.startswith("mj") and not inner_type.name.startswith(
|
elif inner_type.name.startswith("mj") and not inner_type.name.startswith(
|
||||||
"mjt"
|
"mjt"
|
||||||
):
|
):
|
||||||
debug_print(f"\tarray to vector wrapper needed: {self.field.name}")
|
|
||||||
return self._get_manual_definition(comment_type="array field")
|
return self._get_manual_definition(comment_type="array field")
|
||||||
|
|
||||||
debug_print(f"\tNOT IMPLEMENTED ARRAY field: {self.field.name}")
|
|
||||||
return WrappedFieldData(
|
return WrappedFieldData(
|
||||||
definition=(
|
definition=(
|
||||||
f"// TODO: NOT IMPLEMENTED ARRAY wrapper for {self.field.name}"
|
f"// TODO: NOT IMPLEMENTED ARRAY wrapper for {self.field.name}"
|
||||||
@@ -727,8 +716,6 @@ def generate_wasm_bindings(
|
|||||||
else:
|
else:
|
||||||
raise RuntimeError(f"Struct not found: {struct_name}")
|
raise RuntimeError(f"Struct not found: {struct_name}")
|
||||||
|
|
||||||
debug_print(f"Wrapping struct: {struct_name}")
|
|
||||||
|
|
||||||
wrapped_fields: List[WrappedFieldData] = []
|
wrapped_fields: List[WrappedFieldData] = []
|
||||||
for field in struct_fields:
|
for field in struct_fields:
|
||||||
wrapped_field = StructFieldHandler(field, wrapped_name).generate()
|
wrapped_field = StructFieldHandler(field, wrapped_name).generate()
|
||||||
|
|||||||
Reference in New Issue
Block a user