repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
d0c-s4vage/pfp | pfp/fields.py | Struct._pfp__is_non_consecutive_duplicate | def _pfp__is_non_consecutive_duplicate(self, name, child):
"""Return True/False if the child is a non-consecutive duplicately named
field. Consecutive duplicately-named fields are stored in an implicit array,
non-consecutive duplicately named fields have a numeric suffix appended to their name""... | python | def _pfp__is_non_consecutive_duplicate(self, name, child):
"""Return True/False if the child is a non-consecutive duplicately named
field. Consecutive duplicately-named fields are stored in an implicit array,
non-consecutive duplicately named fields have a numeric suffix appended to their name""... | [
"def",
"_pfp__is_non_consecutive_duplicate",
"(",
"self",
",",
"name",
",",
"child",
")",
":",
"if",
"len",
"(",
"self",
".",
"_pfp__children",
")",
"==",
"0",
":",
"return",
"False",
"# it should be an implicit array",
"if",
"self",
".",
"_pfp__children",
"[",
... | Return True/False if the child is a non-consecutive duplicately named
field. Consecutive duplicately-named fields are stored in an implicit array,
non-consecutive duplicately named fields have a numeric suffix appended to their name | [
"Return",
"True",
"/",
"False",
"if",
"the",
"child",
"is",
"a",
"non",
"-",
"consecutive",
"duplicately",
"named",
"field",
".",
"Consecutive",
"duplicately",
"-",
"named",
"fields",
"are",
"stored",
"in",
"an",
"implicit",
"array",
"non",
"-",
"consecutive... | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L691-L710 |
d0c-s4vage/pfp | pfp/fields.py | Struct._pfp__handle_implicit_array | def _pfp__handle_implicit_array(self, name, child):
"""Handle inserting implicit array elements
"""
existing_child = self._pfp__children_map[name]
if isinstance(existing_child, Array):
# I don't think we should check this
#
#if existing_child.field_cls... | python | def _pfp__handle_implicit_array(self, name, child):
"""Handle inserting implicit array elements
"""
existing_child = self._pfp__children_map[name]
if isinstance(existing_child, Array):
# I don't think we should check this
#
#if existing_child.field_cls... | [
"def",
"_pfp__handle_implicit_array",
"(",
"self",
",",
"name",
",",
"child",
")",
":",
"existing_child",
"=",
"self",
".",
"_pfp__children_map",
"[",
"name",
"]",
"if",
"isinstance",
"(",
"existing_child",
",",
"Array",
")",
":",
"# I don't think we should check ... | Handle inserting implicit array elements | [
"Handle",
"inserting",
"implicit",
"array",
"elements"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L712-L742 |
d0c-s4vage/pfp | pfp/fields.py | Struct._pfp__parse | def _pfp__parse(self, stream, save_offset=False):
"""Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
res = 0
for child in self._pfp__children:
... | python | def _pfp__parse(self, stream, save_offset=False):
"""Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
res = 0
for child in self._pfp__children:
... | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"res",
"=",
"0",
"for",
"child",
"in",
"self",
".",
"_pfp__childr... | Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed | [
"Parse",
"the",
"incoming",
"stream"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L744-L757 |
d0c-s4vage/pfp | pfp/fields.py | Struct._pfp__build | def _pfp__build(self, stream=None, save_offset=False):
"""Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None
"""
if save_offset and stream is not None:
self._pfp__offset = stream.tell()
# returns... | python | def _pfp__build(self, stream=None, save_offset=False):
"""Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None
"""
if save_offset and stream is not None:
self._pfp__offset = stream.tell()
# returns... | [
"def",
"_pfp__build",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
"and",
"stream",
"is",
"not",
"None",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"# returns eithe... | Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None | [
"Build",
"the",
"field",
"and",
"write",
"the",
"result",
"into",
"the",
"stream"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L759-L777 |
d0c-s4vage/pfp | pfp/fields.py | Struct._pfp__show | def _pfp__show(self, level=0, include_offset=False):
"""Show the contents of the struct
"""
res = []
res.append("{}{} {{".format(
"{:04x} ".format(self._pfp__offset) if include_offset else "",
self._pfp__show_name
))
for child in self._pfp__childre... | python | def _pfp__show(self, level=0, include_offset=False):
"""Show the contents of the struct
"""
res = []
res.append("{}{} {{".format(
"{:04x} ".format(self._pfp__offset) if include_offset else "",
self._pfp__show_name
))
for child in self._pfp__childre... | [
"def",
"_pfp__show",
"(",
"self",
",",
"level",
"=",
"0",
",",
"include_offset",
"=",
"False",
")",
":",
"res",
"=",
"[",
"]",
"res",
".",
"append",
"(",
"\"{}{} {{\"",
".",
"format",
"(",
"\"{:04x} \"",
".",
"format",
"(",
"self",
".",
"_pfp__offset",... | Show the contents of the struct | [
"Show",
"the",
"contents",
"of",
"the",
"struct"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L816-L832 |
d0c-s4vage/pfp | pfp/fields.py | Union._pfp__add_child | def _pfp__add_child(self, name, child, stream=None):
"""Add a child to the Union field
:name: The name of the child
:child: A :class:`.Field` instance
:returns: The resulting field
"""
res = super(Union, self)._pfp__add_child(name, child)
self._pfp__buff.seek(0, ... | python | def _pfp__add_child(self, name, child, stream=None):
"""Add a child to the Union field
:name: The name of the child
:child: A :class:`.Field` instance
:returns: The resulting field
"""
res = super(Union, self)._pfp__add_child(name, child)
self._pfp__buff.seek(0, ... | [
"def",
"_pfp__add_child",
"(",
"self",
",",
"name",
",",
"child",
",",
"stream",
"=",
"None",
")",
":",
"res",
"=",
"super",
"(",
"Union",
",",
"self",
")",
".",
"_pfp__add_child",
"(",
"name",
",",
"child",
")",
"self",
".",
"_pfp__buff",
".",
"seek... | Add a child to the Union field
:name: The name of the child
:child: A :class:`.Field` instance
:returns: The resulting field | [
"Add",
"a",
"child",
"to",
"the",
"Union",
"field"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L851-L868 |
d0c-s4vage/pfp | pfp/fields.py | Union._pfp__notify_update | def _pfp__notify_update(self, child=None):
"""Handle a child with an updated value
"""
if getattr(self, "_pfp__union_update_other_children", True):
self._pfp__union_update_other_children = False
new_data = child._pfp__build()
new_stream = bitwrap.BitwrappedS... | python | def _pfp__notify_update(self, child=None):
"""Handle a child with an updated value
"""
if getattr(self, "_pfp__union_update_other_children", True):
self._pfp__union_update_other_children = False
new_data = child._pfp__build()
new_stream = bitwrap.BitwrappedS... | [
"def",
"_pfp__notify_update",
"(",
"self",
",",
"child",
"=",
"None",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"\"_pfp__union_update_other_children\"",
",",
"True",
")",
":",
"self",
".",
"_pfp__union_update_other_children",
"=",
"False",
"new_data",
"=",
"c... | Handle a child with an updated value | [
"Handle",
"a",
"child",
"with",
"an",
"updated",
"value"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L870-L890 |
d0c-s4vage/pfp | pfp/fields.py | Union._pfp__parse | def _pfp__parse(self, stream, save_offset=False):
"""Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
max_res = 0
for child in self._pfp__children:
... | python | def _pfp__parse(self, stream, save_offset=False):
"""Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
max_res = 0
for child in self._pfp__children:
... | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"max_res",
"=",
"0",
"for",
"child",
"in",
"self",
".",
"_pfp__ch... | Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed | [
"Parse",
"the",
"incoming",
"stream"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L892-L912 |
d0c-s4vage/pfp | pfp/fields.py | Union._pfp__build | def _pfp__build(self, stream=None, save_offset=False):
"""Build the union and write the result into the stream.
:stream: None
:returns: None
"""
max_size = -1
if stream is None:
core_stream = six.BytesIO()
new_stream = bitwrap.BitwrappedStream(cor... | python | def _pfp__build(self, stream=None, save_offset=False):
"""Build the union and write the result into the stream.
:stream: None
:returns: None
"""
max_size = -1
if stream is None:
core_stream = six.BytesIO()
new_stream = bitwrap.BitwrappedStream(cor... | [
"def",
"_pfp__build",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"save_offset",
"=",
"False",
")",
":",
"max_size",
"=",
"-",
"1",
"if",
"stream",
"is",
"None",
":",
"core_stream",
"=",
"six",
".",
"BytesIO",
"(",
")",
"new_stream",
"=",
"bitwrap",
... | Build the union and write the result into the stream.
:stream: None
:returns: None | [
"Build",
"the",
"union",
"and",
"write",
"the",
"result",
"into",
"the",
"stream",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L914-L941 |
d0c-s4vage/pfp | pfp/fields.py | NumberBase._pfp__parse | def _pfp__parse(self, stream, save_offset=False):
"""Parse the IO stream for this numeric field
:stream: An IO stream that can be read from
:returns: The number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
if self.bitsize is None:
... | python | def _pfp__parse(self, stream, save_offset=False):
"""Parse the IO stream for this numeric field
:stream: An IO stream that can be read from
:returns: The number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
if self.bitsize is None:
... | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"if",
"self",
".",
"bitsize",
"is",
"None",
":",
"raw_data",
"=",... | Parse the IO stream for this numeric field
:stream: An IO stream that can be read from
:returns: The number of bytes parsed | [
"Parse",
"the",
"IO",
"stream",
"for",
"this",
"numeric",
"field"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1032-L1068 |
d0c-s4vage/pfp | pfp/fields.py | NumberBase._pfp__build | def _pfp__build(self, stream=None, save_offset=False):
"""Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None
"""
if stream is not None and save_offset:
self._pfp__offset = stream.tell()
if self.b... | python | def _pfp__build(self, stream=None, save_offset=False):
"""Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None
"""
if stream is not None and save_offset:
self._pfp__offset = stream.tell()
if self.b... | [
"def",
"_pfp__build",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"stream",
"is",
"not",
"None",
"and",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"if",
"self",
... | Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None | [
"Build",
"the",
"field",
"and",
"write",
"the",
"result",
"into",
"the",
"stream"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1070-L1107 |
d0c-s4vage/pfp | pfp/fields.py | NumberBase._dom_class | def _dom_class(self, obj1, obj2):
"""Return the dominating numeric class between the two
:obj1: TODO
:obj2: TODO
:returns: TODO
"""
if isinstance(obj1, Double) or isinstance(obj2, Double):
return Double
if isinstance(obj1, Float) or isinstance(obj2, ... | python | def _dom_class(self, obj1, obj2):
"""Return the dominating numeric class between the two
:obj1: TODO
:obj2: TODO
:returns: TODO
"""
if isinstance(obj1, Double) or isinstance(obj2, Double):
return Double
if isinstance(obj1, Float) or isinstance(obj2, ... | [
"def",
"_dom_class",
"(",
"self",
",",
"obj1",
",",
"obj2",
")",
":",
"if",
"isinstance",
"(",
"obj1",
",",
"Double",
")",
"or",
"isinstance",
"(",
"obj2",
",",
"Double",
")",
":",
"return",
"Double",
"if",
"isinstance",
"(",
"obj1",
",",
"Float",
")... | Return the dominating numeric class between the two
:obj1: TODO
:obj2: TODO
:returns: TODO | [
"Return",
"the",
"dominating",
"numeric",
"class",
"between",
"the",
"two"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1109-L1120 |
d0c-s4vage/pfp | pfp/fields.py | IntBase._pfp__set_value | def _pfp__set_value(self, new_val):
"""Set the value, potentially converting an unsigned
value to a signed one (and visa versa)"""
if self._pfp__frozen:
raise errors.UnmodifiableConst()
if isinstance(new_val, IntBase):
# will automatically convert correctly betwe... | python | def _pfp__set_value(self, new_val):
"""Set the value, potentially converting an unsigned
value to a signed one (and visa versa)"""
if self._pfp__frozen:
raise errors.UnmodifiableConst()
if isinstance(new_val, IntBase):
# will automatically convert correctly betwe... | [
"def",
"_pfp__set_value",
"(",
"self",
",",
"new_val",
")",
":",
"if",
"self",
".",
"_pfp__frozen",
":",
"raise",
"errors",
".",
"UnmodifiableConst",
"(",
")",
"if",
"isinstance",
"(",
"new_val",
",",
"IntBase",
")",
":",
"# will automatically convert correctly ... | Set the value, potentially converting an unsigned
value to a signed one (and visa versa) | [
"Set",
"the",
"value",
"potentially",
"converting",
"an",
"unsigned",
"value",
"to",
"a",
"signed",
"one",
"(",
"and",
"visa",
"versa",
")"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1247-L1289 |
d0c-s4vage/pfp | pfp/fields.py | Enum._pfp__parse | def _pfp__parse(self, stream, save_offset=False):
"""Parse the IO stream for this enum
:stream: An IO stream that can be read from
:returns: The number of bytes parsed
"""
res = super(Enum, self)._pfp__parse(stream, save_offset)
if self._pfp__value in self.enum_vals:
... | python | def _pfp__parse(self, stream, save_offset=False):
"""Parse the IO stream for this enum
:stream: An IO stream that can be read from
:returns: The number of bytes parsed
"""
res = super(Enum, self)._pfp__parse(stream, save_offset)
if self._pfp__value in self.enum_vals:
... | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"res",
"=",
"super",
"(",
"Enum",
",",
"self",
")",
".",
"_pfp__parse",
"(",
"stream",
",",
"save_offset",
")",
"if",
"self",
".",
"_pfp__value",
"in",
"self"... | Parse the IO stream for this enum
:stream: An IO stream that can be read from
:returns: The number of bytes parsed | [
"Parse",
"the",
"IO",
"stream",
"for",
"this",
"enum"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1410-L1423 |
d0c-s4vage/pfp | pfp/fields.py | Array._pfp__snapshot | def _pfp__snapshot(self, recurse=True):
"""Save off the current value of the field
"""
super(Array, self)._pfp__snapshot(recurse=recurse)
self.snapshot_raw_data = self.raw_data
if recurse:
for item in self.items:
item._pfp__snapshot(recurse=recurse) | python | def _pfp__snapshot(self, recurse=True):
"""Save off the current value of the field
"""
super(Array, self)._pfp__snapshot(recurse=recurse)
self.snapshot_raw_data = self.raw_data
if recurse:
for item in self.items:
item._pfp__snapshot(recurse=recurse) | [
"def",
"_pfp__snapshot",
"(",
"self",
",",
"recurse",
"=",
"True",
")",
":",
"super",
"(",
"Array",
",",
"self",
")",
".",
"_pfp__snapshot",
"(",
"recurse",
"=",
"recurse",
")",
"self",
".",
"snapshot_raw_data",
"=",
"self",
".",
"raw_data",
"if",
"recur... | Save off the current value of the field | [
"Save",
"off",
"the",
"current",
"value",
"of",
"the",
"field"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1475-L1483 |
d0c-s4vage/pfp | pfp/fields.py | String._pfp__set_value | def _pfp__set_value(self, new_val):
"""Set the value of the String, taking into account
escaping and such as well
"""
if not isinstance(new_val, Field):
new_val = utils.binary(utils.string_escape(new_val))
super(String, self)._pfp__set_value(new_val) | python | def _pfp__set_value(self, new_val):
"""Set the value of the String, taking into account
escaping and such as well
"""
if not isinstance(new_val, Field):
new_val = utils.binary(utils.string_escape(new_val))
super(String, self)._pfp__set_value(new_val) | [
"def",
"_pfp__set_value",
"(",
"self",
",",
"new_val",
")",
":",
"if",
"not",
"isinstance",
"(",
"new_val",
",",
"Field",
")",
":",
"new_val",
"=",
"utils",
".",
"binary",
"(",
"utils",
".",
"string_escape",
"(",
"new_val",
")",
")",
"super",
"(",
"Str... | Set the value of the String, taking into account
escaping and such as well | [
"Set",
"the",
"value",
"of",
"the",
"String",
"taking",
"into",
"account",
"escaping",
"and",
"such",
"as",
"well"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1743-L1749 |
d0c-s4vage/pfp | pfp/fields.py | String._pfp__parse | def _pfp__parse(self, stream, save_offset=False):
"""Read from the stream until the string is null-terminated
:stream: The input stream
:returns: None
"""
if save_offset:
self._pfp__offset = stream.tell()
res = utils.binary("")
while True:
... | python | def _pfp__parse(self, stream, save_offset=False):
"""Read from the stream until the string is null-terminated
:stream: The input stream
:returns: None
"""
if save_offset:
self._pfp__offset = stream.tell()
res = utils.binary("")
while True:
... | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"res",
"=",
"utils",
".",
"binary",
"(",
"\"\"",
")",
"while",
... | Read from the stream until the string is null-terminated
:stream: The input stream
:returns: None | [
"Read",
"from",
"the",
"stream",
"until",
"the",
"string",
"is",
"null",
"-",
"terminated"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1751-L1771 |
d0c-s4vage/pfp | pfp/fields.py | String._pfp__build | def _pfp__build(self, stream=None, save_offset=False):
"""Build the String field
:stream: TODO
:returns: TODO
"""
if stream is not None and save_offset:
self._pfp__offset = stream.tell()
data = self._pfp__value + utils.binary("\x00")
if stream is No... | python | def _pfp__build(self, stream=None, save_offset=False):
"""Build the String field
:stream: TODO
:returns: TODO
"""
if stream is not None and save_offset:
self._pfp__offset = stream.tell()
data = self._pfp__value + utils.binary("\x00")
if stream is No... | [
"def",
"_pfp__build",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"stream",
"is",
"not",
"None",
"and",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"data",
"=",
... | Build the String field
:stream: TODO
:returns: TODO | [
"Build",
"the",
"String",
"field"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1773-L1788 |
d0c-s4vage/pfp | pfp/native/compat_interface.py | Printf | def Printf(params, ctxt, scope, stream, coord, interp):
"""Prints format string to stdout
:params: TODO
:returns: TODO
"""
if len(params) == 1:
if interp._printf:
sys.stdout.write(PYSTR(params[0]))
return len(PYSTR(params[0]))
parts = []
for part in params[1:]:... | python | def Printf(params, ctxt, scope, stream, coord, interp):
"""Prints format string to stdout
:params: TODO
:returns: TODO
"""
if len(params) == 1:
if interp._printf:
sys.stdout.write(PYSTR(params[0]))
return len(PYSTR(params[0]))
parts = []
for part in params[1:]:... | [
"def",
"Printf",
"(",
"params",
",",
"ctxt",
",",
"scope",
",",
"stream",
",",
"coord",
",",
"interp",
")",
":",
"if",
"len",
"(",
"params",
")",
"==",
"1",
":",
"if",
"interp",
".",
"_printf",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"PYSTR... | Prints format string to stdout
:params: TODO
:returns: TODO | [
"Prints",
"format",
"string",
"to",
"stdout"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/compat_interface.py#L542-L567 |
d0c-s4vage/pfp | pfp/fuzz/__init__.py | mutate | def mutate(field, strat_name_or_cls, num=100, at_once=1, yield_changed=False):
"""Mutate the provided field (probably a Dom or struct instance) using the
strategy specified with ``strat_name_or_class``, yielding ``num`` mutations
that affect up to ``at_once`` fields at once.
This function will yield ba... | python | def mutate(field, strat_name_or_cls, num=100, at_once=1, yield_changed=False):
"""Mutate the provided field (probably a Dom or struct instance) using the
strategy specified with ``strat_name_or_class``, yielding ``num`` mutations
that affect up to ``at_once`` fields at once.
This function will yield ba... | [
"def",
"mutate",
"(",
"field",
",",
"strat_name_or_cls",
",",
"num",
"=",
"100",
",",
"at_once",
"=",
"1",
",",
"yield_changed",
"=",
"False",
")",
":",
"import",
"pfp",
".",
"fuzz",
".",
"rand",
"as",
"rand",
"init",
"(",
")",
"strat",
"=",
"get_str... | Mutate the provided field (probably a Dom or struct instance) using the
strategy specified with ``strat_name_or_class``, yielding ``num`` mutations
that affect up to ``at_once`` fields at once.
This function will yield back the field after each mutation, optionally
also yielding a ``set`` of fields tha... | [
"Mutate",
"the",
"provided",
"field",
"(",
"probably",
"a",
"Dom",
"or",
"struct",
"instance",
")",
"using",
"the",
"strategy",
"specified",
"with",
"strat_name_or_class",
"yielding",
"num",
"mutations",
"that",
"affect",
"up",
"to",
"at_once",
"fields",
"at",
... | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fuzz/__init__.py#L39-L103 |
d0c-s4vage/pfp | pfp/fuzz/strats.py | get_strategy | def get_strategy(name_or_cls):
"""Return the strategy identified by its name. If ``name_or_class`` is a class,
it will be simply returned.
"""
if isinstance(name_or_cls, six.string_types):
if name_or_cls not in STRATS:
raise MutationError("strat is not defined")
return STRATS... | python | def get_strategy(name_or_cls):
"""Return the strategy identified by its name. If ``name_or_class`` is a class,
it will be simply returned.
"""
if isinstance(name_or_cls, six.string_types):
if name_or_cls not in STRATS:
raise MutationError("strat is not defined")
return STRATS... | [
"def",
"get_strategy",
"(",
"name_or_cls",
")",
":",
"if",
"isinstance",
"(",
"name_or_cls",
",",
"six",
".",
"string_types",
")",
":",
"if",
"name_or_cls",
"not",
"in",
"STRATS",
":",
"raise",
"MutationError",
"(",
"\"strat is not defined\"",
")",
"return",
"... | Return the strategy identified by its name. If ``name_or_class`` is a class,
it will be simply returned. | [
"Return",
"the",
"strategy",
"identified",
"by",
"its",
"name",
".",
"If",
"name_or_class",
"is",
"a",
"class",
"it",
"will",
"be",
"simply",
"returned",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fuzz/strats.py#L29-L38 |
d0c-s4vage/pfp | pfp/fuzz/strats.py | FieldStrat.mutate | def mutate(self, field):
"""Mutate the given field, modifying it directly. This is not
intended to preserve the value of the field.
:field: The pfp.fields.Field instance that will receive the new value
"""
new_val = self.next_val(field)
field._pfp__set_value(new_val)
... | python | def mutate(self, field):
"""Mutate the given field, modifying it directly. This is not
intended to preserve the value of the field.
:field: The pfp.fields.Field instance that will receive the new value
"""
new_val = self.next_val(field)
field._pfp__set_value(new_val)
... | [
"def",
"mutate",
"(",
"self",
",",
"field",
")",
":",
"new_val",
"=",
"self",
".",
"next_val",
"(",
"field",
")",
"field",
".",
"_pfp__set_value",
"(",
"new_val",
")",
"return",
"field"
] | Mutate the given field, modifying it directly. This is not
intended to preserve the value of the field.
:field: The pfp.fields.Field instance that will receive the new value | [
"Mutate",
"the",
"given",
"field",
"modifying",
"it",
"directly",
".",
"This",
"is",
"not",
"intended",
"to",
"preserve",
"the",
"value",
"of",
"the",
"field",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fuzz/strats.py#L194-L202 |
d0c-s4vage/pfp | pfp/fuzz/strats.py | FieldStrat.next_val | def next_val(self, field):
"""Return a new value to mutate a field with. Do not modify the field directly
in this function. Override the ``mutate()`` function if that is needed (the field is
only passed into this function as a reference).
:field: The pfp.fields.Field instance that will ... | python | def next_val(self, field):
"""Return a new value to mutate a field with. Do not modify the field directly
in this function. Override the ``mutate()`` function if that is needed (the field is
only passed into this function as a reference).
:field: The pfp.fields.Field instance that will ... | [
"def",
"next_val",
"(",
"self",
",",
"field",
")",
":",
"import",
"pfp",
".",
"fuzz",
".",
"rand",
"as",
"rand",
"if",
"self",
".",
"choices",
"is",
"not",
"None",
":",
"choices",
"=",
"self",
".",
"_resolve_member_val",
"(",
"self",
".",
"choices",
... | Return a new value to mutate a field with. Do not modify the field directly
in this function. Override the ``mutate()`` function if that is needed (the field is
only passed into this function as a reference).
:field: The pfp.fields.Field instance that will receive the new value. Passed in for r... | [
"Return",
"a",
"new",
"value",
"to",
"mutate",
"a",
"field",
"with",
".",
"Do",
"not",
"modify",
"the",
"field",
"directly",
"in",
"this",
"function",
".",
"Override",
"the",
"mutate",
"()",
"function",
"if",
"that",
"is",
"needed",
"(",
"the",
"field",
... | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fuzz/strats.py#L204-L232 |
expfactory/expfactory | expfactory/database/relational.py | generate_subid | def generate_subid(self, token=None, return_user=False):
'''generate a new user in the database, still session based so we
create a new identifier.
'''
from expfactory.database.models import Participant
if not token:
p = Participant()
else:
p = Participant(token=token)
... | python | def generate_subid(self, token=None, return_user=False):
'''generate a new user in the database, still session based so we
create a new identifier.
'''
from expfactory.database.models import Participant
if not token:
p = Participant()
else:
p = Participant(token=token)
... | [
"def",
"generate_subid",
"(",
"self",
",",
"token",
"=",
"None",
",",
"return_user",
"=",
"False",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"if",
"not",
"token",
":",
"p",
"=",
"Participant",
"(",
")",
"els... | generate a new user in the database, still session based so we
create a new identifier. | [
"generate",
"a",
"new",
"user",
"in",
"the",
"database",
"still",
"session",
"based",
"so",
"we",
"create",
"a",
"new",
"identifier",
"."
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L65-L78 |
expfactory/expfactory | expfactory/database/relational.py | print_user | def print_user(self, user):
'''print a relational database user
'''
status = "active"
token = user.token
if token in ['finished', 'revoked']:
status = token
if token is None:
token = ''
subid = "%s\t%s[%s]" %(user.id, token, status)
print(subid)
return subid | python | def print_user(self, user):
'''print a relational database user
'''
status = "active"
token = user.token
if token in ['finished', 'revoked']:
status = token
if token is None:
token = ''
subid = "%s\t%s[%s]" %(user.id, token, status)
print(subid)
return subid | [
"def",
"print_user",
"(",
"self",
",",
"user",
")",
":",
"status",
"=",
"\"active\"",
"token",
"=",
"user",
".",
"token",
"if",
"token",
"in",
"[",
"'finished'",
",",
"'revoked'",
"]",
":",
"status",
"=",
"token",
"if",
"token",
"is",
"None",
":",
"t... | print a relational database user | [
"print",
"a",
"relational",
"database",
"user"
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L81-L95 |
expfactory/expfactory | expfactory/database/relational.py | list_users | def list_users(self, user=None):
'''list users, each having a model in the database. A headless experiment
will use protected tokens, and interactive will be based on auto-
incremented ids.
'''
from expfactory.database.models import Participant
participants = Participant.query.all()
u... | python | def list_users(self, user=None):
'''list users, each having a model in the database. A headless experiment
will use protected tokens, and interactive will be based on auto-
incremented ids.
'''
from expfactory.database.models import Participant
participants = Participant.query.all()
u... | [
"def",
"list_users",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"participants",
"=",
"Participant",
".",
"query",
".",
"all",
"(",
")",
"users",
"=",
"[",
"]",
"for",
... | list users, each having a model in the database. A headless experiment
will use protected tokens, and interactive will be based on auto-
incremented ids. | [
"list",
"users",
"each",
"having",
"a",
"model",
"in",
"the",
"database",
".",
"A",
"headless",
"experiment",
"will",
"use",
"protected",
"tokens",
"and",
"interactive",
"will",
"be",
"based",
"on",
"auto",
"-",
"incremented",
"ids",
"."
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L98-L108 |
expfactory/expfactory | expfactory/database/relational.py | generate_user | def generate_user(self):
'''generate a new user in the database, still session based so we
create a new identifier. This function is called from the users new
entrypoint, and it assumes we want a user generated with a token.
'''
token = str(uuid.uuid4())
return self.generate_subid(token=t... | python | def generate_user(self):
'''generate a new user in the database, still session based so we
create a new identifier. This function is called from the users new
entrypoint, and it assumes we want a user generated with a token.
'''
token = str(uuid.uuid4())
return self.generate_subid(token=t... | [
"def",
"generate_user",
"(",
"self",
")",
":",
"token",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"return",
"self",
".",
"generate_subid",
"(",
"token",
"=",
"token",
",",
"return_user",
"=",
"True",
")"
] | generate a new user in the database, still session based so we
create a new identifier. This function is called from the users new
entrypoint, and it assumes we want a user generated with a token. | [
"generate",
"a",
"new",
"user",
"in",
"the",
"database",
"still",
"session",
"based",
"so",
"we",
"create",
"a",
"new",
"identifier",
".",
"This",
"function",
"is",
"called",
"from",
"the",
"users",
"new",
"entrypoint",
"and",
"it",
"assumes",
"we",
"want"... | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L113-L119 |
expfactory/expfactory | expfactory/database/relational.py | finish_user | def finish_user(self, subid):
'''finish user will remove a user's token, making the user entry not
accesible if running in headless model'''
p = self.revoke_token(subid)
p.token = "finished"
self.session.commit()
return p | python | def finish_user(self, subid):
'''finish user will remove a user's token, making the user entry not
accesible if running in headless model'''
p = self.revoke_token(subid)
p.token = "finished"
self.session.commit()
return p | [
"def",
"finish_user",
"(",
"self",
",",
"subid",
")",
":",
"p",
"=",
"self",
".",
"revoke_token",
"(",
"subid",
")",
"p",
".",
"token",
"=",
"\"finished\"",
"self",
".",
"session",
".",
"commit",
"(",
")",
"return",
"p"
] | finish user will remove a user's token, making the user entry not
accesible if running in headless model | [
"finish",
"user",
"will",
"remove",
"a",
"user",
"s",
"token",
"making",
"the",
"user",
"entry",
"not",
"accesible",
"if",
"running",
"in",
"headless",
"model"
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L122-L129 |
expfactory/expfactory | expfactory/database/relational.py | restart_user | def restart_user(self, subid):
'''restart a user, which means revoking and issuing a new token.'''
p = self.revoke_token(subid)
p = self.refresh_token(subid)
return p | python | def restart_user(self, subid):
'''restart a user, which means revoking and issuing a new token.'''
p = self.revoke_token(subid)
p = self.refresh_token(subid)
return p | [
"def",
"restart_user",
"(",
"self",
",",
"subid",
")",
":",
"p",
"=",
"self",
".",
"revoke_token",
"(",
"subid",
")",
"p",
"=",
"self",
".",
"refresh_token",
"(",
"subid",
")",
"return",
"p"
] | restart a user, which means revoking and issuing a new token. | [
"restart",
"a",
"user",
"which",
"means",
"revoking",
"and",
"issuing",
"a",
"new",
"token",
"."
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L132-L136 |
expfactory/expfactory | expfactory/database/relational.py | validate_token | def validate_token(self, token):
'''retrieve a subject based on a token. Valid means we return a participant
invalid means we return None
'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.token == token).first()
if p is not None:
if p.toke... | python | def validate_token(self, token):
'''retrieve a subject based on a token. Valid means we return a participant
invalid means we return None
'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.token == token).first()
if p is not None:
if p.toke... | [
"def",
"validate_token",
"(",
"self",
",",
"token",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"p",
"=",
"Participant",
".",
"query",
".",
"filter",
"(",
"Participant",
".",
"token",
"==",
"token",
")",
".",
... | retrieve a subject based on a token. Valid means we return a participant
invalid means we return None | [
"retrieve",
"a",
"subject",
"based",
"on",
"a",
"token",
".",
"Valid",
"means",
"we",
"return",
"a",
"participant",
"invalid",
"means",
"we",
"return",
"None"
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L142-L153 |
expfactory/expfactory | expfactory/database/relational.py | revoke_token | def revoke_token(self, subid):
'''revoke a token by removing it. Is done at finish, and also available
as a command line option'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.id == subid).first()
if p is not None:
p.token = 'revoked'
self.s... | python | def revoke_token(self, subid):
'''revoke a token by removing it. Is done at finish, and also available
as a command line option'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.id == subid).first()
if p is not None:
p.token = 'revoked'
self.s... | [
"def",
"revoke_token",
"(",
"self",
",",
"subid",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"p",
"=",
"Participant",
".",
"query",
".",
"filter",
"(",
"Participant",
".",
"id",
"==",
"subid",
")",
".",
"firs... | revoke a token by removing it. Is done at finish, and also available
as a command line option | [
"revoke",
"a",
"token",
"by",
"removing",
"it",
".",
"Is",
"done",
"at",
"finish",
"and",
"also",
"available",
"as",
"a",
"command",
"line",
"option"
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L156-L164 |
expfactory/expfactory | expfactory/database/relational.py | refresh_token | def refresh_token(self, subid):
'''refresh or generate a new token for a user'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.id == subid).first()
if p is not None:
p.token = str(uuid.uuid4())
self.session.commit()
return p | python | def refresh_token(self, subid):
'''refresh or generate a new token for a user'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.id == subid).first()
if p is not None:
p.token = str(uuid.uuid4())
self.session.commit()
return p | [
"def",
"refresh_token",
"(",
"self",
",",
"subid",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"p",
"=",
"Participant",
".",
"query",
".",
"filter",
"(",
"Participant",
".",
"id",
"==",
"subid",
")",
".",
"fir... | refresh or generate a new token for a user | [
"refresh",
"or",
"generate",
"a",
"new",
"token",
"for",
"a",
"user"
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L167-L174 |
expfactory/expfactory | expfactory/database/relational.py | save_data | def save_data(self,session, exp_id, content):
'''save data will obtain the current subid from the session, and save it
depending on the database type. Currently we just support flat files'''
from expfactory.database.models import (
Participant,
Result
)
subid = session.get('subid'... | python | def save_data(self,session, exp_id, content):
'''save data will obtain the current subid from the session, and save it
depending on the database type. Currently we just support flat files'''
from expfactory.database.models import (
Participant,
Result
)
subid = session.get('subid'... | [
"def",
"save_data",
"(",
"self",
",",
"session",
",",
"exp_id",
",",
"content",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"(",
"Participant",
",",
"Result",
")",
"subid",
"=",
"session",
".",
"get",
"(",
"'subid'",
")",
... | save data will obtain the current subid from the session, and save it
depending on the database type. Currently we just support flat files | [
"save",
"data",
"will",
"obtain",
"the",
"current",
"subid",
"from",
"the",
"session",
"and",
"save",
"it",
"depending",
"on",
"the",
"database",
"type",
".",
"Currently",
"we",
"just",
"support",
"flat",
"files"
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L177-L213 |
expfactory/expfactory | expfactory/database/relational.py | init_db | def init_db(self):
'''initialize the database, with the default database path or custom with
a format corresponding to the database type:
Examples:
sqlite:////scif/data/expfactory.db
'''
# The user can provide a custom string
if self.database is None:
self.logger.error("Y... | python | def init_db(self):
'''initialize the database, with the default database path or custom with
a format corresponding to the database type:
Examples:
sqlite:////scif/data/expfactory.db
'''
# The user can provide a custom string
if self.database is None:
self.logger.error("Y... | [
"def",
"init_db",
"(",
"self",
")",
":",
"# The user can provide a custom string",
"if",
"self",
".",
"database",
"is",
"None",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"You must provide a database url, exiting.\"",
")",
"sys",
".",
"exit",
"(",
"1",
")"... | initialize the database, with the default database path or custom with
a format corresponding to the database type:
Examples:
sqlite:////scif/data/expfactory.db | [
"initialize",
"the",
"database",
"with",
"the",
"default",
"database",
"path",
"or",
"custom",
"with",
"a",
"format",
"corresponding",
"to",
"the",
"database",
"type",
":"
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L219-L246 |
d0c-s4vage/pfp | pfp/interp.py | LazyField | def LazyField(lookup_name, scope):
"""Super non-standard stuff here. Dynamically changing the base
class using the scope and the lazy name when the class is
instantiated. This works as long as the original base class is
not directly inheriting from object (which we're not, since
our original base cl... | python | def LazyField(lookup_name, scope):
"""Super non-standard stuff here. Dynamically changing the base
class using the scope and the lazy name when the class is
instantiated. This works as long as the original base class is
not directly inheriting from object (which we're not, since
our original base cl... | [
"def",
"LazyField",
"(",
"lookup_name",
",",
"scope",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"stream",
"=",
"None",
")",
":",
"base_cls",
"=",
"self",
".",
"_pfp__scope",
".",
"get_id",
"(",
"self",
".",
"_pfp__lazy_name",
")",
"self",
".",
"__... | Super non-standard stuff here. Dynamically changing the base
class using the scope and the lazy name when the class is
instantiated. This works as long as the original base class is
not directly inheriting from object (which we're not, since
our original base class is fields.Field). | [
"Super",
"non",
"-",
"standard",
"stuff",
"here",
".",
"Dynamically",
"changing",
"the",
"base",
"class",
"using",
"the",
"scope",
"and",
"the",
"lazy",
"name",
"when",
"the",
"class",
"is",
"instantiated",
".",
"This",
"works",
"as",
"long",
"as",
"the",
... | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L113-L130 |
d0c-s4vage/pfp | pfp/interp.py | PfpTypes._wrap_type_instantiation | def _wrap_type_instantiation(self, type_cls):
"""Wrap the creation of the type so that we can provide
a null-stream to initialize it"""
def wrapper(*args, **kwargs):
# use args for struct arguments??
return type_cls(stream=self._null_stream)
return wrapper | python | def _wrap_type_instantiation(self, type_cls):
"""Wrap the creation of the type so that we can provide
a null-stream to initialize it"""
def wrapper(*args, **kwargs):
# use args for struct arguments??
return type_cls(stream=self._null_stream)
return wrapper | [
"def",
"_wrap_type_instantiation",
"(",
"self",
",",
"type_cls",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# use args for struct arguments??",
"return",
"type_cls",
"(",
"stream",
"=",
"self",
".",
"_null_stream",
")",
... | Wrap the creation of the type so that we can provide
a null-stream to initialize it | [
"Wrap",
"the",
"creation",
"of",
"the",
"type",
"so",
"that",
"we",
"can",
"provide",
"a",
"null",
"-",
"stream",
"to",
"initialize",
"it"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L241-L247 |
d0c-s4vage/pfp | pfp/interp.py | Scope.level | def level(self):
"""Return the current scope level
"""
res = len(self._scope_stack)
if self._parent is not None:
res += self._parent.level()
return res | python | def level(self):
"""Return the current scope level
"""
res = len(self._scope_stack)
if self._parent is not None:
res += self._parent.level()
return res | [
"def",
"level",
"(",
"self",
")",
":",
"res",
"=",
"len",
"(",
"self",
".",
"_scope_stack",
")",
"if",
"self",
".",
"_parent",
"is",
"not",
"None",
":",
"res",
"+=",
"self",
".",
"_parent",
".",
"level",
"(",
")",
"return",
"res"
] | Return the current scope level | [
"Return",
"the",
"current",
"scope",
"level"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L273-L279 |
d0c-s4vage/pfp | pfp/interp.py | Scope.push | def push(self, new_scope=None):
"""Create a new scope
:returns: TODO
"""
if new_scope is None:
new_scope = {
"types": {},
"vars": {}
}
self._curr_scope = new_scope
self._dlog("pushing new scope, scope level = {}".fo... | python | def push(self, new_scope=None):
"""Create a new scope
:returns: TODO
"""
if new_scope is None:
new_scope = {
"types": {},
"vars": {}
}
self._curr_scope = new_scope
self._dlog("pushing new scope, scope level = {}".fo... | [
"def",
"push",
"(",
"self",
",",
"new_scope",
"=",
"None",
")",
":",
"if",
"new_scope",
"is",
"None",
":",
"new_scope",
"=",
"{",
"\"types\"",
":",
"{",
"}",
",",
"\"vars\"",
":",
"{",
"}",
"}",
"self",
".",
"_curr_scope",
"=",
"new_scope",
"self",
... | Create a new scope
:returns: TODO | [
"Create",
"a",
"new",
"scope",
":",
"returns",
":",
"TODO"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L281-L293 |
d0c-s4vage/pfp | pfp/interp.py | Scope.clone | def clone(self):
"""Return a new Scope object that has the curr_scope
pinned at the current one
:returns: A new scope object
"""
self._dlog("cloning the stack")
# TODO is this really necessary to create a brand new one?
# I think it is... need to think about it mo... | python | def clone(self):
"""Return a new Scope object that has the curr_scope
pinned at the current one
:returns: A new scope object
"""
self._dlog("cloning the stack")
# TODO is this really necessary to create a brand new one?
# I think it is... need to think about it mo... | [
"def",
"clone",
"(",
"self",
")",
":",
"self",
".",
"_dlog",
"(",
"\"cloning the stack\"",
")",
"# TODO is this really necessary to create a brand new one?",
"# I think it is... need to think about it more.",
"# or... are we going to need ref counters and a global",
"# scope object tha... | Return a new Scope object that has the curr_scope
pinned at the current one
:returns: A new scope object | [
"Return",
"a",
"new",
"Scope",
"object",
"that",
"has",
"the",
"curr_scope",
"pinned",
"at",
"the",
"current",
"one",
":",
"returns",
":",
"A",
"new",
"scope",
"object"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L295-L309 |
d0c-s4vage/pfp | pfp/interp.py | Scope.pop | def pop(self):
"""Leave the current scope
:returns: TODO
"""
res = self._scope_stack.pop()
self._dlog("popping scope, scope level = {}".format(self.level()))
self._curr_scope = self._scope_stack[-1]
return res | python | def pop(self):
"""Leave the current scope
:returns: TODO
"""
res = self._scope_stack.pop()
self._dlog("popping scope, scope level = {}".format(self.level()))
self._curr_scope = self._scope_stack[-1]
return res | [
"def",
"pop",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_scope_stack",
".",
"pop",
"(",
")",
"self",
".",
"_dlog",
"(",
"\"popping scope, scope level = {}\"",
".",
"format",
"(",
"self",
".",
"level",
"(",
")",
")",
")",
"self",
".",
"_curr_scop... | Leave the current scope
:returns: TODO | [
"Leave",
"the",
"current",
"scope",
":",
"returns",
":",
"TODO"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L311-L319 |
d0c-s4vage/pfp | pfp/interp.py | Scope.add_var | def add_var(self, field_name, field, root=False):
"""Add a var to the current scope (vars are fields that
parse the input stream)
:field_name: TODO
:field: TODO
:returns: TODO
"""
self._dlog("adding var '{}' (root={})".format(field_name, root))
# do bot... | python | def add_var(self, field_name, field, root=False):
"""Add a var to the current scope (vars are fields that
parse the input stream)
:field_name: TODO
:field: TODO
:returns: TODO
"""
self._dlog("adding var '{}' (root={})".format(field_name, root))
# do bot... | [
"def",
"add_var",
"(",
"self",
",",
"field_name",
",",
"field",
",",
"root",
"=",
"False",
")",
":",
"self",
".",
"_dlog",
"(",
"\"adding var '{}' (root={})\"",
".",
"format",
"(",
"field_name",
",",
"root",
")",
")",
"# do both so it's not clobbered by intermed... | Add a var to the current scope (vars are fields that
parse the input stream)
:field_name: TODO
:field: TODO
:returns: TODO | [
"Add",
"a",
"var",
"to",
"the",
"current",
"scope",
"(",
"vars",
"are",
"fields",
"that",
"parse",
"the",
"input",
"stream",
")"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L321-L337 |
d0c-s4vage/pfp | pfp/interp.py | Scope.get_var | def get_var(self, name, recurse=True):
"""Return the first var of name ``name`` in the current
scope stack (remember, vars are the ones that parse the
input stream)
:name: The name of the id
:recurse: Whether parent scopes should also be searched (defaults to True)
:retu... | python | def get_var(self, name, recurse=True):
"""Return the first var of name ``name`` in the current
scope stack (remember, vars are the ones that parse the
input stream)
:name: The name of the id
:recurse: Whether parent scopes should also be searched (defaults to True)
:retu... | [
"def",
"get_var",
"(",
"self",
",",
"name",
",",
"recurse",
"=",
"True",
")",
":",
"self",
".",
"_dlog",
"(",
"\"getting var '{}'\"",
".",
"format",
"(",
"name",
")",
")",
"return",
"self",
".",
"_search",
"(",
"\"vars\"",
",",
"name",
",",
"recurse",
... | Return the first var of name ``name`` in the current
scope stack (remember, vars are the ones that parse the
input stream)
:name: The name of the id
:recurse: Whether parent scopes should also be searched (defaults to True)
:returns: TODO | [
"Return",
"the",
"first",
"var",
"of",
"name",
"name",
"in",
"the",
"current",
"scope",
"stack",
"(",
"remember",
"vars",
"are",
"the",
"ones",
"that",
"parse",
"the",
"input",
"stream",
")"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L340-L351 |
d0c-s4vage/pfp | pfp/interp.py | Scope.add_local | def add_local(self, field_name, field):
"""Add a local variable in the current scope
:field_name: The field's name
:field: The field
:returns: None
"""
self._dlog("adding local '{}'".format(field_name))
field._pfp__name = field_name
# TODO do we allow cl... | python | def add_local(self, field_name, field):
"""Add a local variable in the current scope
:field_name: The field's name
:field: The field
:returns: None
"""
self._dlog("adding local '{}'".format(field_name))
field._pfp__name = field_name
# TODO do we allow cl... | [
"def",
"add_local",
"(",
"self",
",",
"field_name",
",",
"field",
")",
":",
"self",
".",
"_dlog",
"(",
"\"adding local '{}'\"",
".",
"format",
"(",
"field_name",
")",
")",
"field",
".",
"_pfp__name",
"=",
"field_name",
"# TODO do we allow clobbering of locals???",... | Add a local variable in the current scope
:field_name: The field's name
:field: The field
:returns: None | [
"Add",
"a",
"local",
"variable",
"in",
"the",
"current",
"scope"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L353-L364 |
d0c-s4vage/pfp | pfp/interp.py | Scope.get_local | def get_local(self, name, recurse=True):
"""Get the local field (search for it) from the scope stack. An alias
for ``get_var``
:name: The name of the local field
"""
self._dlog("getting local '{}'".format(name))
return self._search("vars", name, recurse) | python | def get_local(self, name, recurse=True):
"""Get the local field (search for it) from the scope stack. An alias
for ``get_var``
:name: The name of the local field
"""
self._dlog("getting local '{}'".format(name))
return self._search("vars", name, recurse) | [
"def",
"get_local",
"(",
"self",
",",
"name",
",",
"recurse",
"=",
"True",
")",
":",
"self",
".",
"_dlog",
"(",
"\"getting local '{}'\"",
".",
"format",
"(",
"name",
")",
")",
"return",
"self",
".",
"_search",
"(",
"\"vars\"",
",",
"name",
",",
"recurs... | Get the local field (search for it) from the scope stack. An alias
for ``get_var``
:name: The name of the local field | [
"Get",
"the",
"local",
"field",
"(",
"search",
"for",
"it",
")",
"from",
"the",
"scope",
"stack",
".",
"An",
"alias",
"for",
"get_var"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L366-L373 |
d0c-s4vage/pfp | pfp/interp.py | Scope.add_type_struct_or_union | def add_type_struct_or_union(self, name, interp, node):
"""Store the node with the name. When it is instantiated,
the node itself will be handled.
:name: name of the typedefd struct/union
:node: the union/struct node
:interp: the 010 interpreter
"""
self.add_type... | python | def add_type_struct_or_union(self, name, interp, node):
"""Store the node with the name. When it is instantiated,
the node itself will be handled.
:name: name of the typedefd struct/union
:node: the union/struct node
:interp: the 010 interpreter
"""
self.add_type... | [
"def",
"add_type_struct_or_union",
"(",
"self",
",",
"name",
",",
"interp",
",",
"node",
")",
":",
"self",
".",
"add_type_class",
"(",
"name",
",",
"StructUnionDef",
"(",
"name",
",",
"interp",
",",
"node",
")",
")"
] | Store the node with the name. When it is instantiated,
the node itself will be handled.
:name: name of the typedefd struct/union
:node: the union/struct node
:interp: the 010 interpreter | [
"Store",
"the",
"node",
"with",
"the",
"name",
".",
"When",
"it",
"is",
"instantiated",
"the",
"node",
"itself",
"will",
"be",
"handled",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L380-L388 |
d0c-s4vage/pfp | pfp/interp.py | Scope.add_type | def add_type(self, new_name, orig_names):
"""Record the typedefd name for orig_names. Resolve orig_names
to their core names and save those.
:new_name: TODO
:orig_names: TODO
:returns: TODO
"""
self._dlog("adding a type '{}'".format(new_name))
# TODO do ... | python | def add_type(self, new_name, orig_names):
"""Record the typedefd name for orig_names. Resolve orig_names
to their core names and save those.
:new_name: TODO
:orig_names: TODO
:returns: TODO
"""
self._dlog("adding a type '{}'".format(new_name))
# TODO do ... | [
"def",
"add_type",
"(",
"self",
",",
"new_name",
",",
"orig_names",
")",
":",
"self",
".",
"_dlog",
"(",
"\"adding a type '{}'\"",
".",
"format",
"(",
"new_name",
")",
")",
"# TODO do we allow clobbering of types???",
"res",
"=",
"copy",
".",
"copy",
"(",
"ori... | Record the typedefd name for orig_names. Resolve orig_names
to their core names and save those.
:new_name: TODO
:orig_names: TODO
:returns: TODO | [
"Record",
"the",
"typedefd",
"name",
"for",
"orig_names",
".",
"Resolve",
"orig_names",
"to",
"their",
"core",
"names",
"and",
"save",
"those",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L390-L407 |
d0c-s4vage/pfp | pfp/interp.py | Scope.get_type | def get_type(self, name, recurse=True):
"""Get the names for the typename (created by typedef)
:name: The typedef'd name to resolve
:returns: An array of resolved names associated with the typedef'd name
"""
self._dlog("getting type '{}'".format(name))
return self._sear... | python | def get_type(self, name, recurse=True):
"""Get the names for the typename (created by typedef)
:name: The typedef'd name to resolve
:returns: An array of resolved names associated with the typedef'd name
"""
self._dlog("getting type '{}'".format(name))
return self._sear... | [
"def",
"get_type",
"(",
"self",
",",
"name",
",",
"recurse",
"=",
"True",
")",
":",
"self",
".",
"_dlog",
"(",
"\"getting type '{}'\"",
".",
"format",
"(",
"name",
")",
")",
"return",
"self",
".",
"_search",
"(",
"\"types\"",
",",
"name",
",",
"recurse... | Get the names for the typename (created by typedef)
:name: The typedef'd name to resolve
:returns: An array of resolved names associated with the typedef'd name | [
"Get",
"the",
"names",
"for",
"the",
"typename",
"(",
"created",
"by",
"typedef",
")"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L409-L417 |
d0c-s4vage/pfp | pfp/interp.py | Scope.get_id | def get_id(self, name, recurse=True):
"""Get the first id matching ``name``. Will either be a local
or a var.
:name: TODO
:returns: TODO
"""
self._dlog("getting id '{}'".format(name))
var = self._search("vars", name, recurse)
return var | python | def get_id(self, name, recurse=True):
"""Get the first id matching ``name``. Will either be a local
or a var.
:name: TODO
:returns: TODO
"""
self._dlog("getting id '{}'".format(name))
var = self._search("vars", name, recurse)
return var | [
"def",
"get_id",
"(",
"self",
",",
"name",
",",
"recurse",
"=",
"True",
")",
":",
"self",
".",
"_dlog",
"(",
"\"getting id '{}'\"",
".",
"format",
"(",
"name",
")",
")",
"var",
"=",
"self",
".",
"_search",
"(",
"\"vars\"",
",",
"name",
",",
"recurse"... | Get the first id matching ``name``. Will either be a local
or a var.
:name: TODO
:returns: TODO | [
"Get",
"the",
"first",
"id",
"matching",
"name",
".",
"Will",
"either",
"be",
"a",
"local",
"or",
"a",
"var",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L419-L429 |
d0c-s4vage/pfp | pfp/interp.py | Scope._resolve_name | def _resolve_name(self, name):
"""TODO: Docstring for _resolve_names.
:name: TODO
:returns: TODO
"""
res = [name]
while True:
orig_names = self._search("types", name)
if orig_names is not None:
name = orig_names[-1]
... | python | def _resolve_name(self, name):
"""TODO: Docstring for _resolve_names.
:name: TODO
:returns: TODO
"""
res = [name]
while True:
orig_names = self._search("types", name)
if orig_names is not None:
name = orig_names[-1]
... | [
"def",
"_resolve_name",
"(",
"self",
",",
"name",
")",
":",
"res",
"=",
"[",
"name",
"]",
"while",
"True",
":",
"orig_names",
"=",
"self",
".",
"_search",
"(",
"\"types\"",
",",
"name",
")",
"if",
"orig_names",
"is",
"not",
"None",
":",
"name",
"=",
... | TODO: Docstring for _resolve_names.
:name: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_resolve_names",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L438-L457 |
d0c-s4vage/pfp | pfp/interp.py | Scope._search | def _search(self, category, name, recurse=True):
"""Search the scope stack for the name in the specified
category (types/locals/vars).
:category: the category to search in (locals/types/vars)
:name: name to search for
:returns: None if not found, the result of the found local/ty... | python | def _search(self, category, name, recurse=True):
"""Search the scope stack for the name in the specified
category (types/locals/vars).
:category: the category to search in (locals/types/vars)
:name: name to search for
:returns: None if not found, the result of the found local/ty... | [
"def",
"_search",
"(",
"self",
",",
"category",
",",
"name",
",",
"recurse",
"=",
"True",
")",
":",
"idx",
"=",
"len",
"(",
"self",
".",
"_scope_stack",
")",
"-",
"1",
"curr",
"=",
"self",
".",
"_curr_scope",
"for",
"scope",
"in",
"reversed",
"(",
... | Search the scope stack for the name in the specified
category (types/locals/vars).
:category: the category to search in (locals/types/vars)
:name: name to search for
:returns: None if not found, the result of the found local/type/id | [
"Search",
"the",
"scope",
"stack",
"for",
"the",
"name",
"in",
"the",
"specified",
"category",
"(",
"types",
"/",
"locals",
"/",
"vars",
")",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L459-L477 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp.add_native | def add_native(cls, name, func, ret, interp=None, send_interp=False):
"""Add the native python function ``func`` into the pfp interpreter with the
name ``name`` and return value ``ret`` so that it can be called from
within a template script.
.. note::
The :any:`@native <pfp.... | python | def add_native(cls, name, func, ret, interp=None, send_interp=False):
"""Add the native python function ``func`` into the pfp interpreter with the
name ``name`` and return value ``ret`` so that it can be called from
within a template script.
.. note::
The :any:`@native <pfp.... | [
"def",
"add_native",
"(",
"cls",
",",
"name",
",",
"func",
",",
"ret",
",",
"interp",
"=",
"None",
",",
"send_interp",
"=",
"False",
")",
":",
"if",
"interp",
"is",
"None",
":",
"natives",
"=",
"cls",
".",
"_natives",
"else",
":",
"# the instance's nat... | Add the native python function ``func`` into the pfp interpreter with the
name ``name`` and return value ``ret`` so that it can be called from
within a template script.
.. note::
The :any:`@native <pfp.native.native>` decorator exists to simplify this.
All native functions ... | [
"Add",
"the",
"native",
"python",
"function",
"func",
"into",
"the",
"pfp",
"interpreter",
"with",
"the",
"name",
"name",
"and",
"return",
"value",
"ret",
"so",
"that",
"it",
"can",
"be",
"called",
"from",
"within",
"a",
"template",
"script",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L501-L538 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp.define_natives | def define_natives(cls):
"""Define the native functions for PFP
"""
if len(cls._natives) > 0:
return
glob_pattern = os.path.join(os.path.dirname(__file__), "native", "*.py")
for filename in glob.glob(glob_pattern):
basename = os.path.basename(filename).re... | python | def define_natives(cls):
"""Define the native functions for PFP
"""
if len(cls._natives) > 0:
return
glob_pattern = os.path.join(os.path.dirname(__file__), "native", "*.py")
for filename in glob.glob(glob_pattern):
basename = os.path.basename(filename).re... | [
"def",
"define_natives",
"(",
"cls",
")",
":",
"if",
"len",
"(",
"cls",
".",
"_natives",
")",
">",
"0",
":",
"return",
"glob_pattern",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"\"native... | Define the native functions for PFP | [
"Define",
"the",
"native",
"functions",
"for",
"PFP"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L550-L571 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._dlog | def _dlog(self, msg, indent_increase=0):
"""log the message to the log"""
self._log.debug("interp", msg, indent_increase, filename=self._orig_filename, coord=self._coord) | python | def _dlog(self, msg, indent_increase=0):
"""log the message to the log"""
self._log.debug("interp", msg, indent_increase, filename=self._orig_filename, coord=self._coord) | [
"def",
"_dlog",
"(",
"self",
",",
"msg",
",",
"indent_increase",
"=",
"0",
")",
":",
"self",
".",
"_log",
".",
"debug",
"(",
"\"interp\"",
",",
"msg",
",",
"indent_increase",
",",
"filename",
"=",
"self",
".",
"_orig_filename",
",",
"coord",
"=",
"self... | log the message to the log | [
"log",
"the",
"message",
"to",
"the",
"log"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L651-L653 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp.parse | def parse(self, stream, template, predefines=True, orig_filename=None, keep_successful=False, printf=True):
"""Parse the data stream using the template (e.g. parse the 010 template
and interpret the template using the stream as the data source).
:stream: The input data stream
:template:... | python | def parse(self, stream, template, predefines=True, orig_filename=None, keep_successful=False, printf=True):
"""Parse the data stream using the template (e.g. parse the 010 template
and interpret the template using the stream as the data source).
:stream: The input data stream
:template:... | [
"def",
"parse",
"(",
"self",
",",
"stream",
",",
"template",
",",
"predefines",
"=",
"True",
",",
"orig_filename",
"=",
"None",
",",
"keep_successful",
"=",
"False",
",",
"printf",
"=",
"True",
")",
":",
"self",
".",
"_dlog",
"(",
"\"parsing\"",
")",
"... | Parse the data stream using the template (e.g. parse the 010 template
and interpret the template using the stream as the data source).
:stream: The input data stream
:template: The template to parse the stream with
:keep_successful: Return whatever was successfully parsed before an erro... | [
"Parse",
"the",
"data",
"stream",
"using",
"the",
"template",
"(",
"e",
".",
"g",
".",
"parse",
"the",
"010",
"template",
"and",
"interpret",
"the",
"template",
"using",
"the",
"stream",
"as",
"the",
"data",
"source",
")",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L659-L681 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp.eval | def eval(self, statement, ctxt=None):
"""Eval a single statement (something returnable)
"""
self._no_debug = True
statement = statement.strip()
if not statement.endswith(";"):
statement += ";"
ast = self._parse_string(statement, predefines=False)
s... | python | def eval(self, statement, ctxt=None):
"""Eval a single statement (something returnable)
"""
self._no_debug = True
statement = statement.strip()
if not statement.endswith(";"):
statement += ";"
ast = self._parse_string(statement, predefines=False)
s... | [
"def",
"eval",
"(",
"self",
",",
"statement",
",",
"ctxt",
"=",
"None",
")",
":",
"self",
".",
"_no_debug",
"=",
"True",
"statement",
"=",
"statement",
".",
"strip",
"(",
")",
"if",
"not",
"statement",
".",
"endswith",
"(",
"\";\"",
")",
":",
"statem... | Eval a single statement (something returnable) | [
"Eval",
"a",
"single",
"statement",
"(",
"something",
"returnable",
")"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L698-L720 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp.set_break | def set_break(self, break_type):
"""Set if the interpreter should break.
:returns: TODO
"""
self._break_type = break_type
self._break_level = self._scope.level() | python | def set_break(self, break_type):
"""Set if the interpreter should break.
:returns: TODO
"""
self._break_type = break_type
self._break_level = self._scope.level() | [
"def",
"set_break",
"(",
"self",
",",
"break_type",
")",
":",
"self",
".",
"_break_type",
"=",
"break_type",
"self",
".",
"_break_level",
"=",
"self",
".",
"_scope",
".",
"level",
"(",
")"
] | Set if the interpreter should break.
:returns: TODO | [
"Set",
"if",
"the",
"interpreter",
"should",
"break",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L722-L728 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp.get_curr_lines | def get_curr_lines(self):
"""Return the current line number in the template,
as well as the surrounding source lines
"""
start = max(0, self._coord.line - 5)
end = min(len(self._template_lines), self._coord.line + 4)
lines = [(x, self._template_lines[x]) for x in six.mov... | python | def get_curr_lines(self):
"""Return the current line number in the template,
as well as the surrounding source lines
"""
start = max(0, self._coord.line - 5)
end = min(len(self._template_lines), self._coord.line + 4)
lines = [(x, self._template_lines[x]) for x in six.mov... | [
"def",
"get_curr_lines",
"(",
"self",
")",
":",
"start",
"=",
"max",
"(",
"0",
",",
"self",
".",
"_coord",
".",
"line",
"-",
"5",
")",
"end",
"=",
"min",
"(",
"len",
"(",
"self",
".",
"_template_lines",
")",
",",
"self",
".",
"_coord",
".",
"line... | Return the current line number in the template,
as well as the surrounding source lines | [
"Return",
"the",
"current",
"line",
"number",
"in",
"the",
"template",
"as",
"well",
"as",
"the",
"surrounding",
"source",
"lines"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L730-L738 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp.set_bitfield_padded | def set_bitfield_padded(self, val):
"""Set if the bitfield input/output stream should be padded
:val: True/False
:returns: None
"""
self._padded_bitfield = val
self._stream.padded = val
self._ctxt._pfp__padded_bitfield = val | python | def set_bitfield_padded(self, val):
"""Set if the bitfield input/output stream should be padded
:val: True/False
:returns: None
"""
self._padded_bitfield = val
self._stream.padded = val
self._ctxt._pfp__padded_bitfield = val | [
"def",
"set_bitfield_padded",
"(",
"self",
",",
"val",
")",
":",
"self",
".",
"_padded_bitfield",
"=",
"val",
"self",
".",
"_stream",
".",
"padded",
"=",
"val",
"self",
".",
"_ctxt",
".",
"_pfp__padded_bitfield",
"=",
"val"
] | Set if the bitfield input/output stream should be padded
:val: True/False
:returns: None | [
"Set",
"if",
"the",
"bitfield",
"input",
"/",
"output",
"stream",
"should",
"be",
"padded"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L740-L748 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._run | def _run(self, keep_successfull):
"""Interpret the parsed 010 AST
:returns: PfpDom
"""
# example self._ast.show():
# FileAST:
# Decl: data, [], [], []
# TypeDecl: data, []
# Struct: DATA
# Decl: a, [], [], []
... | python | def _run(self, keep_successfull):
"""Interpret the parsed 010 AST
:returns: PfpDom
"""
# example self._ast.show():
# FileAST:
# Decl: data, [], [], []
# TypeDecl: data, []
# Struct: DATA
# Decl: a, [], [], []
... | [
"def",
"_run",
"(",
"self",
",",
"keep_successfull",
")",
":",
"# example self._ast.show():",
"# FileAST:",
"# Decl: data, [], [], []",
"# TypeDecl: data, []",
"# Struct: DATA",
"# Decl: a, [], [], []",
"# TypeDecl: a, []",
"# ... | Interpret the parsed 010 AST
:returns: PfpDom | [
"Interpret",
"the",
"parsed",
"010",
"AST",
":",
"returns",
":",
"PfpDom"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L823-L883 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_node | def _handle_node(self, node, scope=None, ctxt=None, stream=None):
"""Recursively handle nodes in the 010 AST
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
if scope is None:
if self._scope is None:
self._... | python | def _handle_node(self, node, scope=None, ctxt=None, stream=None):
"""Recursively handle nodes in the 010 AST
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
if scope is None:
if self._scope is None:
self._... | [
"def",
"_handle_node",
"(",
"self",
",",
"node",
",",
"scope",
"=",
"None",
",",
"ctxt",
"=",
"None",
",",
"stream",
"=",
"None",
")",
":",
"if",
"scope",
"is",
"None",
":",
"if",
"self",
".",
"_scope",
"is",
"None",
":",
"self",
".",
"_scope",
"... | Recursively handle nodes in the 010 AST
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Recursively",
"handle",
"nodes",
"in",
"the",
"010",
"AST"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L885-L949 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_file_ast | def _handle_file_ast(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_file_ast.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._root = ctxt = fields.Dom(stream)
ctxt._pfp__scope = scope
self._ro... | python | def _handle_file_ast(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_file_ast.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._root = ctxt = fields.Dom(stream)
ctxt._pfp__scope = scope
self._ro... | [
"def",
"_handle_file_ast",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_root",
"=",
"ctxt",
"=",
"fields",
".",
"Dom",
"(",
"stream",
")",
"ctxt",
".",
"_pfp__scope",
"=",
"scope",
"self",
".",
"_root",... | TODO: Docstring for _handle_file_ast.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_file_ast",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L951-L972 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_cast | def _handle_cast(self, node, scope, ctxt, stream):
"""Handle cast nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling cast")
to_type = self._handle_node(node.to_type, scope, ctxt, stream)
val_t... | python | def _handle_cast(self, node, scope, ctxt, stream):
"""Handle cast nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling cast")
to_type = self._handle_node(node.to_type, scope, ctxt, stream)
val_t... | [
"def",
"_handle_cast",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling cast\"",
")",
"to_type",
"=",
"self",
".",
"_handle_node",
"(",
"node",
".",
"to_type",
",",
"scope",
",",
"ctxt... | Handle cast nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"cast",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L986-L1002 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_typename | def _handle_typename(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_typename
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling typename")
return self._handle_node(node.type, scope, ctxt,... | python | def _handle_typename(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_typename
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling typename")
return self._handle_node(node.type, scope, ctxt,... | [
"def",
"_handle_typename",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling typename\"",
")",
"return",
"self",
".",
"_handle_node",
"(",
"node",
".",
"type",
",",
"scope",
",",
"ctxt",
... | TODO: Docstring for _handle_typename
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_typename"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1004-L1016 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._get_node_name | def _get_node_name(self, node):
"""Get the name of the node - check for node.name and
node.type.declname. Not sure why the second one occurs
exactly - it happens with declaring a new struct field
with parameters"""
res = getattr(node, "name", None)
if res is None:
... | python | def _get_node_name(self, node):
"""Get the name of the node - check for node.name and
node.type.declname. Not sure why the second one occurs
exactly - it happens with declaring a new struct field
with parameters"""
res = getattr(node, "name", None)
if res is None:
... | [
"def",
"_get_node_name",
"(",
"self",
",",
"node",
")",
":",
"res",
"=",
"getattr",
"(",
"node",
",",
"\"name\"",
",",
"None",
")",
"if",
"res",
"is",
"None",
":",
"return",
"res",
"if",
"isinstance",
"(",
"res",
",",
"AST",
".",
"TypeDecl",
")",
"... | Get the name of the node - check for node.name and
node.type.declname. Not sure why the second one occurs
exactly - it happens with declaring a new struct field
with parameters | [
"Get",
"the",
"name",
"of",
"the",
"node",
"-",
"check",
"for",
"node",
".",
"name",
"and",
"node",
".",
"type",
".",
"declname",
".",
"Not",
"sure",
"why",
"the",
"second",
"one",
"occurs",
"exactly",
"-",
"it",
"happens",
"with",
"declaring",
"a",
... | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1018-L1030 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_decl | def _handle_decl(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling decl")
metadata_processor = None
if node.metadata is not N... | python | def _handle_decl(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling decl")
metadata_processor = None
if node.metadata is not N... | [
"def",
"_handle_decl",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling decl\"",
")",
"metadata_processor",
"=",
"None",
"if",
"node",
".",
"metadata",
"is",
"not",
"None",
":",
"#metada... | TODO: Docstring for _handle_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_decl",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1032-L1189 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_metadata | def _handle_metadata(self, node, scope, ctxt, stream):
"""Handle metadata for the node
"""
self._dlog("handling node metadata {}".format(node.metadata.keyvals))
keyvals = node.metadata.keyvals
metadata_info = []
if "watch" in node.metadata.keyvals or "update" in keyval... | python | def _handle_metadata(self, node, scope, ctxt, stream):
"""Handle metadata for the node
"""
self._dlog("handling node metadata {}".format(node.metadata.keyvals))
keyvals = node.metadata.keyvals
metadata_info = []
if "watch" in node.metadata.keyvals or "update" in keyval... | [
"def",
"_handle_metadata",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling node metadata {}\"",
".",
"format",
"(",
"node",
".",
"metadata",
".",
"keyvals",
")",
")",
"keyvals",
"=",
"n... | Handle metadata for the node | [
"Handle",
"metadata",
"for",
"the",
"node"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1191-L1210 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_watch_metadata | def _handle_watch_metadata(self, node, scope, ctxt, stream):
"""Handle watch vars for fields
"""
keyvals = node.metadata.keyvals
if "watch" not in keyvals:
raise errors.PfpError("Packed fields require a packer function set")
if "update" not in keyvals:
rai... | python | def _handle_watch_metadata(self, node, scope, ctxt, stream):
"""Handle watch vars for fields
"""
keyvals = node.metadata.keyvals
if "watch" not in keyvals:
raise errors.PfpError("Packed fields require a packer function set")
if "update" not in keyvals:
rai... | [
"def",
"_handle_watch_metadata",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"keyvals",
"=",
"node",
".",
"metadata",
".",
"keyvals",
"if",
"\"watch\"",
"not",
"in",
"keyvals",
":",
"raise",
"errors",
".",
"PfpError",
"(... | Handle watch vars for fields | [
"Handle",
"watch",
"vars",
"for",
"fields"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1216-L1236 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_packed_metadata | def _handle_packed_metadata(self, node, scope, ctxt, stream):
"""Handle packed metadata
"""
keyvals = node.metadata.keyvals
if "packer" not in keyvals and ("pack" not in keyvals or "unpack" not in keyvals):
raise errors.PfpError("Packed fields require a packer function to be ... | python | def _handle_packed_metadata(self, node, scope, ctxt, stream):
"""Handle packed metadata
"""
keyvals = node.metadata.keyvals
if "packer" not in keyvals and ("pack" not in keyvals or "unpack" not in keyvals):
raise errors.PfpError("Packed fields require a packer function to be ... | [
"def",
"_handle_packed_metadata",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"keyvals",
"=",
"node",
".",
"metadata",
".",
"keyvals",
"if",
"\"packer\"",
"not",
"in",
"keyvals",
"and",
"(",
"\"pack\"",
"not",
"in",
"key... | Handle packed metadata | [
"Handle",
"packed",
"metadata"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1238-L1264 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_byref_decl | def _handle_byref_decl(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_byref_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling byref decl")
field = self._handle_node(node.type.type, ... | python | def _handle_byref_decl(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_byref_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling byref decl")
field = self._handle_node(node.type.type, ... | [
"def",
"_handle_byref_decl",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling byref decl\"",
")",
"field",
"=",
"self",
".",
"_handle_node",
"(",
"node",
".",
"type",
".",
"type",
",",
... | TODO: Docstring for _handle_byref_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_byref_decl",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1266-L1285 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_type_decl | def _handle_type_decl(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_type_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling type decl")
decl = self._handle_node(node.type, scope, ct... | python | def _handle_type_decl(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_type_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling type decl")
decl = self._handle_node(node.type, scope, ct... | [
"def",
"_handle_type_decl",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling type decl\"",
")",
"decl",
"=",
"self",
".",
"_handle_node",
"(",
"node",
".",
"type",
",",
"scope",
",",
"... | TODO: Docstring for _handle_type_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_type_decl",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1287-L1299 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_struct_ref | def _handle_struct_ref(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_struct_ref.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling struct ref")
# name
# field
struct = s... | python | def _handle_struct_ref(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_struct_ref.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling struct ref")
# name
# field
struct = s... | [
"def",
"_handle_struct_ref",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling struct ref\"",
")",
"# name",
"# field",
"struct",
"=",
"self",
".",
"_handle_node",
"(",
"node",
".",
"name",... | TODO: Docstring for _handle_struct_ref.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_struct_ref",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1301-L1336 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_union | def _handle_union(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_union.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling union")
union_cls = StructUnionDef("union", self, node)
... | python | def _handle_union(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_union.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling union")
union_cls = StructUnionDef("union", self, node)
... | [
"def",
"_handle_union",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling union\"",
")",
"union_cls",
"=",
"StructUnionDef",
"(",
"\"union\"",
",",
"self",
",",
"node",
")",
"return",
"un... | TODO: Docstring for _handle_union.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_union",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1338-L1351 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_init_list | def _handle_init_list(self, node, scope, ctxt, stream):
"""Handle InitList nodes (e.g. when initializing a struct)
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling init list")
res = []
for _,init_... | python | def _handle_init_list(self, node, scope, ctxt, stream):
"""Handle InitList nodes (e.g. when initializing a struct)
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling init list")
res = []
for _,init_... | [
"def",
"_handle_init_list",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling init list\"",
")",
"res",
"=",
"[",
"]",
"for",
"_",
",",
"init_child",
"in",
"node",
".",
"children",
"(",... | Handle InitList nodes (e.g. when initializing a struct)
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"InitList",
"nodes",
"(",
"e",
".",
"g",
".",
"when",
"initializing",
"a",
"struct",
")"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1369-L1384 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_struct_call_type_decl | def _handle_struct_call_type_decl(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_struct_call_type_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling struct with parameters")
struct_... | python | def _handle_struct_call_type_decl(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_struct_call_type_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling struct with parameters")
struct_... | [
"def",
"_handle_struct_call_type_decl",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling struct with parameters\"",
")",
"struct_cls",
"=",
"self",
".",
"_handle_node",
"(",
"node",
".",
"type... | TODO: Docstring for _handle_struct_call_type_decl.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_struct_call_type_decl",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1386-L1402 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_struct | def _handle_struct(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_struct.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling struct")
if node.args is not None:
for param in no... | python | def _handle_struct(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_struct.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling struct")
if node.args is not None:
for param in no... | [
"def",
"_handle_struct",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling struct\"",
")",
"if",
"node",
".",
"args",
"is",
"not",
"None",
":",
"for",
"param",
"in",
"node",
".",
"arg... | TODO: Docstring for _handle_struct.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_struct",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1404-L1432 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_identifier_type | def _handle_identifier_type(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_identifier_type.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling identifier")
cls = self._resolve_to_field_cl... | python | def _handle_identifier_type(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_identifier_type.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling identifier")
cls = self._resolve_to_field_cl... | [
"def",
"_handle_identifier_type",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling identifier\"",
")",
"cls",
"=",
"self",
".",
"_resolve_to_field_class",
"(",
"node",
".",
"names",
",",
"... | TODO: Docstring for _handle_identifier_type.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_identifier_type",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1454-L1467 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_typedef | def _handle_typedef(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_typedef.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
is_union_or_struct = (node.type.type.__class__ in [AST.Union, AST.Struct])
is_enum... | python | def _handle_typedef(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_typedef.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
is_union_or_struct = (node.type.type.__class__ in [AST.Union, AST.Struct])
is_enum... | [
"def",
"_handle_typedef",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"is_union_or_struct",
"=",
"(",
"node",
".",
"type",
".",
"type",
".",
"__class__",
"in",
"[",
"AST",
".",
"Union",
",",
"AST",
".",
"Struct",
"]"... | TODO: Docstring for _handle_typedef.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_typedef",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1469-L1503 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._str_to_int | def _str_to_int(self, string):
"""Check for the hex
"""
string = string.lower()
if string.endswith("l"):
string = string[:-1]
if string.lower().startswith("0x"):
# should always match
match = re.match(r'0[xX]([a-fA-F0-9]+)', string)
... | python | def _str_to_int(self, string):
"""Check for the hex
"""
string = string.lower()
if string.endswith("l"):
string = string[:-1]
if string.lower().startswith("0x"):
# should always match
match = re.match(r'0[xX]([a-fA-F0-9]+)', string)
... | [
"def",
"_str_to_int",
"(",
"self",
",",
"string",
")",
":",
"string",
"=",
"string",
".",
"lower",
"(",
")",
"if",
"string",
".",
"endswith",
"(",
"\"l\"",
")",
":",
"string",
"=",
"string",
"[",
":",
"-",
"1",
"]",
"if",
"string",
".",
"lower",
... | Check for the hex | [
"Check",
"for",
"the",
"hex"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1505-L1516 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_constant | def _handle_constant(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_constant.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling constant type {}".format(node.type))
switch = {
... | python | def _handle_constant(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_constant.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling constant type {}".format(node.type))
switch = {
... | [
"def",
"_handle_constant",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling constant type {}\"",
".",
"format",
"(",
"node",
".",
"type",
")",
")",
"switch",
"=",
"{",
"\"int\"",
":",
... | TODO: Docstring for _handle_constant.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_constant",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1528-L1567 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_binary_op | def _handle_binary_op(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_binary_op.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling binary operation {}".format(node.op))
switch = {
... | python | def _handle_binary_op(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_binary_op.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling binary operation {}".format(node.op))
switch = {
... | [
"def",
"_handle_binary_op",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling binary operation {}\"",
".",
"format",
"(",
"node",
".",
"op",
")",
")",
"switch",
"=",
"{",
"\"+\"",
":",
... | TODO: Docstring for _handle_binary_op.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_binary_op",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1569-L1617 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_unary_op | def _handle_unary_op(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_unary_op.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling unary op {}".format(node.op))
special_switch = {
... | python | def _handle_unary_op(self, node, scope, ctxt, stream):
"""TODO: Docstring for _handle_unary_op.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling unary op {}".format(node.op))
special_switch = {
... | [
"def",
"_handle_unary_op",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling unary op {}\"",
".",
"format",
"(",
"node",
".",
"op",
")",
")",
"special_switch",
"=",
"{",
"\"parentof\"",
"... | TODO: Docstring for _handle_unary_op.
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"TODO",
":",
"Docstring",
"for",
"_handle_unary_op",
"."
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1619-L1665 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_parentof | def _handle_parentof(self, node, scope, ctxt, stream):
"""Handle the parentof unary operator
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
# if someone does something like parentof(this).blah,
# we'll end up with a StructR... | python | def _handle_parentof(self, node, scope, ctxt, stream):
"""Handle the parentof unary operator
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
# if someone does something like parentof(this).blah,
# we'll end up with a StructR... | [
"def",
"_handle_parentof",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"# if someone does something like parentof(this).blah,",
"# we'll end up with a StructRef instead of an ID ref",
"# for node.expr, but we'll also end up with a structref",
"# if... | Handle the parentof unary operator
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"the",
"parentof",
"unary",
"operator"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1681-L1703 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_exists | def _handle_exists(self, node, scope, ctxt, stream):
"""Handle the exists unary operator
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
res = fields.Int()
try:
self._handle_node(node.expr, scope, ctxt, stream)
... | python | def _handle_exists(self, node, scope, ctxt, stream):
"""Handle the exists unary operator
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
res = fields.Int()
try:
self._handle_node(node.expr, scope, ctxt, stream)
... | [
"def",
"_handle_exists",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"res",
"=",
"fields",
".",
"Int",
"(",
")",
"try",
":",
"self",
".",
"_handle_node",
"(",
"node",
".",
"expr",
",",
"scope",
",",
"ctxt",
",",
... | Handle the exists unary operator
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"the",
"exists",
"unary",
"operator"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1705-L1721 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_function_exists | def _handle_function_exists(self, node, scope, ctxt, stream):
"""Handle the function_exists unary operator
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
res = fields.Int()
try:
func = self._handle_node(node.exp... | python | def _handle_function_exists(self, node, scope, ctxt, stream):
"""Handle the function_exists unary operator
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
res = fields.Int()
try:
func = self._handle_node(node.exp... | [
"def",
"_handle_function_exists",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"res",
"=",
"fields",
".",
"Int",
"(",
")",
"try",
":",
"func",
"=",
"self",
".",
"_handle_node",
"(",
"node",
".",
"expr",
",",
"scope",
... | Handle the function_exists unary operator
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"the",
"function_exists",
"unary",
"operator"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1723-L1742 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_id | def _handle_id(self, node, scope, ctxt, stream):
"""Handle an ID node (return a field object for the ID)
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
if node.name == "__root":
return self._root
if node.name ==... | python | def _handle_id(self, node, scope, ctxt, stream):
"""Handle an ID node (return a field object for the ID)
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
if node.name == "__root":
return self._root
if node.name ==... | [
"def",
"_handle_id",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"if",
"node",
".",
"name",
"==",
"\"__root\"",
":",
"return",
"self",
".",
"_root",
"if",
"node",
".",
"name",
"==",
"\"__this\"",
"or",
"node",
".",
... | Handle an ID node (return a field object for the ID)
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"an",
"ID",
"node",
"(",
"return",
"a",
"field",
"object",
"for",
"the",
"ID",
")"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1744-L1769 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_assignment | def _handle_assignment(self, node, scope, ctxt, stream):
"""Handle assignment nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
def add_op(x,y): x += y
def sub_op(x,y): x -= y
def div_op(x,y): x /= y
def ... | python | def _handle_assignment(self, node, scope, ctxt, stream):
"""Handle assignment nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
def add_op(x,y): x += y
def sub_op(x,y): x -= y
def div_op(x,y): x /= y
def ... | [
"def",
"_handle_assignment",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"def",
"add_op",
"(",
"x",
",",
"y",
")",
":",
"x",
"+=",
"y",
"def",
"sub_op",
"(",
"x",
",",
"y",
")",
":",
"x",
"-=",
"y",
"def",
"d... | Handle assignment nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"assignment",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1771-L1819 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_func_def | def _handle_func_def(self, node, scope, ctxt, stream):
"""Handle FuncDef nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling function definition")
func = self._handle_node(node.decl, scope, ctxt, strea... | python | def _handle_func_def(self, node, scope, ctxt, stream):
"""Handle FuncDef nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling function definition")
func = self._handle_node(node.decl, scope, ctxt, strea... | [
"def",
"_handle_func_def",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling function definition\"",
")",
"func",
"=",
"self",
".",
"_handle_node",
"(",
"node",
".",
"decl",
",",
"scope",
... | Handle FuncDef nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"FuncDef",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1821-L1833 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_param_list | def _handle_param_list(self, node, scope, ctxt, stream):
"""Handle ParamList nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling param list")
# params should be a list of tuples:
# [(<name>, <f... | python | def _handle_param_list(self, node, scope, ctxt, stream):
"""Handle ParamList nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling param list")
# params should be a list of tuples:
# [(<name>, <f... | [
"def",
"_handle_param_list",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling param list\"",
")",
"# params should be a list of tuples:",
"# [(<name>, <field_class>), ...]",
"params",
"=",
"[",
"]",... | Handle ParamList nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"ParamList",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1835-L1855 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_func_decl | def _handle_func_decl(self, node, scope, ctxt, stream):
"""Handle FuncDecl nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling func decl")
if node.args is not None:
# could just call _hand... | python | def _handle_func_decl(self, node, scope, ctxt, stream):
"""Handle FuncDecl nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling func decl")
if node.args is not None:
# could just call _hand... | [
"def",
"_handle_func_decl",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling func decl\"",
")",
"if",
"node",
".",
"args",
"is",
"not",
"None",
":",
"# could just call _handle_param_list direc... | Handle FuncDecl nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"FuncDecl",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1857-L1883 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_func_call | def _handle_func_call(self, node, scope, ctxt, stream):
"""Handle FuncCall nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling function call to '{}'".format(node.name.name))
if node.args is None:
... | python | def _handle_func_call(self, node, scope, ctxt, stream):
"""Handle FuncCall nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling function call to '{}'".format(node.name.name))
if node.args is None:
... | [
"def",
"_handle_func_call",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling function call to '{}'\"",
".",
"format",
"(",
"node",
".",
"name",
".",
"name",
")",
")",
"if",
"node",
".",
... | Handle FuncCall nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"FuncCall",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1885-L1901 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_expr_list | def _handle_expr_list(self, node, scope, ctxt, stream):
"""Handle ExprList nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling expression list")
exprs = [
self._handle_node(expr, scope, ctx... | python | def _handle_expr_list(self, node, scope, ctxt, stream):
"""Handle ExprList nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling expression list")
exprs = [
self._handle_node(expr, scope, ctx... | [
"def",
"_handle_expr_list",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling expression list\"",
")",
"exprs",
"=",
"[",
"self",
".",
"_handle_node",
"(",
"expr",
",",
"scope",
",",
"ctx... | Handle ExprList nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"ExprList",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1903-L1917 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_compound | def _handle_compound(self, node, scope, ctxt, stream):
"""Handle Compound nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling compound statement")
#scope.push()
try:
for child in n... | python | def _handle_compound(self, node, scope, ctxt, stream):
"""Handle Compound nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling compound statement")
#scope.push()
try:
for child in n... | [
"def",
"_handle_compound",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling compound statement\"",
")",
"#scope.push()",
"try",
":",
"for",
"child",
"in",
"node",
".",
"children",
"(",
")"... | Handle Compound nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"Compound",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1919-L1940 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_return | def _handle_return(self, node, scope, ctxt, stream):
"""Handle Return nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling return")
if node.expr is None:
ret_val = None
else:
... | python | def _handle_return(self, node, scope, ctxt, stream):
"""Handle Return nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling return")
if node.expr is None:
ret_val = None
else:
... | [
"def",
"_handle_return",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling return\"",
")",
"if",
"node",
".",
"expr",
"is",
"None",
":",
"ret_val",
"=",
"None",
"else",
":",
"ret_val",
... | Handle Return nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"Return",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1942-L1958 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_enum | def _handle_enum(self, node, scope, ctxt, stream):
"""Handle enum nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling enum")
if node.type is None:
enum_cls = fields.Int
else:
... | python | def _handle_enum(self, node, scope, ctxt, stream):
"""Handle enum nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling enum")
if node.type is None:
enum_cls = fields.Int
else:
... | [
"def",
"_handle_enum",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling enum\"",
")",
"if",
"node",
".",
"type",
"is",
"None",
":",
"enum_cls",
"=",
"fields",
".",
"Int",
"else",
":"... | Handle enum nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"enum",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1960-L1997 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_array_decl | def _handle_array_decl(self, node, scope, ctxt, stream):
"""Handle ArrayDecl nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling array declaration '{}'".format(node.type.declname))
if node.dim is None... | python | def _handle_array_decl(self, node, scope, ctxt, stream):
"""Handle ArrayDecl nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling array declaration '{}'".format(node.type.declname))
if node.dim is None... | [
"def",
"_handle_array_decl",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling array declaration '{}'\"",
".",
"format",
"(",
"node",
".",
"type",
".",
"declname",
")",
")",
"if",
"node",
... | Handle ArrayDecl nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"ArrayDecl",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1999-L2025 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_array_ref | def _handle_array_ref(self, node, scope, ctxt, stream):
"""Handle ArrayRef nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
ary = self._handle_node(node.name, scope, ctxt, stream)
subscript = self._handle_node(node.subs... | python | def _handle_array_ref(self, node, scope, ctxt, stream):
"""Handle ArrayRef nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
ary = self._handle_node(node.name, scope, ctxt, stream)
subscript = self._handle_node(node.subs... | [
"def",
"_handle_array_ref",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"ary",
"=",
"self",
".",
"_handle_node",
"(",
"node",
".",
"name",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
"subscript",
"=",
"self",
".",... | Handle ArrayRef nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"ArrayRef",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L2027-L2039 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_if | def _handle_if(self, node, scope, ctxt, stream):
"""Handle If nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling if/ternary_op")
cond = self._handle_node(node.cond, scope, ctxt, stream)
if con... | python | def _handle_if(self, node, scope, ctxt, stream):
"""Handle If nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling if/ternary_op")
cond = self._handle_node(node.cond, scope, ctxt, stream)
if con... | [
"def",
"_handle_if",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling if/ternary_op\"",
")",
"cond",
"=",
"self",
".",
"_handle_node",
"(",
"node",
".",
"cond",
",",
"scope",
",",
"ctx... | Handle If nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"If",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L2041-L2058 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_for | def _handle_for(self, node, scope, ctxt, stream):
"""Handle For nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling for")
if node.init is not None:
# perform the init
self._hand... | python | def _handle_for(self, node, scope, ctxt, stream):
"""Handle For nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling for")
if node.init is not None:
# perform the init
self._hand... | [
"def",
"_handle_for",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling for\"",
")",
"if",
"node",
".",
"init",
"is",
"not",
"None",
":",
"# perform the init",
"self",
".",
"_handle_node"... | Handle For nodes
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"For",
"nodes"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L2060-L2090 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_while | def _handle_while(self, node, scope, ctxt, stream):
"""Handle break node
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling while")
while node.cond is None or self._handle_node(node.cond, scope, ctxt, strea... | python | def _handle_while(self, node, scope, ctxt, stream):
"""Handle break node
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
self._dlog("handling while")
while node.cond is None or self._handle_node(node.cond, scope, ctxt, strea... | [
"def",
"_handle_while",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"self",
".",
"_dlog",
"(",
"\"handling while\"",
")",
"while",
"node",
".",
"cond",
"is",
"None",
"or",
"self",
".",
"_handle_node",
"(",
"node",
".",... | Handle break node
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"break",
"node"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L2092-L2110 |
d0c-s4vage/pfp | pfp/interp.py | PfpInterp._handle_switch | def _handle_switch(self, node, scope, ctxt, stream):
"""Handle break node
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
def exec_case(idx, cases):
# keep executing cases until a break is found,
# or they've... | python | def _handle_switch(self, node, scope, ctxt, stream):
"""Handle break node
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO
"""
def exec_case(idx, cases):
# keep executing cases until a break is found,
# or they've... | [
"def",
"_handle_switch",
"(",
"self",
",",
"node",
",",
"scope",
",",
"ctxt",
",",
"stream",
")",
":",
"def",
"exec_case",
"(",
"idx",
",",
"cases",
")",
":",
"# keep executing cases until a break is found,",
"# or they've all been executed",
"for",
"case",
"in",
... | Handle break node
:node: TODO
:scope: TODO
:ctxt: TODO
:stream: TODO
:returns: TODO | [
"Handle",
"break",
"node"
] | train | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L2143-L2215 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.