MCPcopy Create free account
hub / github.com/nodejs/node / load_fields_from_file

Function load_fields_from_file

deps/v8/tools/gen-postmortem-metadata.py:881–936  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

879
880
881def load_fields_from_file(filename):
882 inlfile = io.open(filename, 'r', encoding='utf-8');
883
884 #
885 # Each class's fields and the corresponding offsets are described in the
886 # source by calls to macros like "ACCESSORS" (and friends). All we do
887 # here is extract these macro invocations, taking into account that they
888 # may span multiple lines and may contain nested parentheses. We also
889 # call parse_field() to pick apart the invocation.
890 #
891 prefixes = [
892 'ACCESSORS', 'ACCESSORS2', 'ACCESSORS_GCSAFE', 'SMI_ACCESSORS',
893 'ACCESSORS_TO_SMI', 'RELEASE_ACQUIRE_ACCESSORS'
894 ]
895 prefixes += ([prefix + "_CHECKED" for prefix in prefixes] +
896 [prefix + "_CHECKED2" for prefix in prefixes])
897 current = ''
898 opens = 0
899
900 for line in inlfile:
901 if (opens > 0):
902 # Continuation line
903 for ii in range(0, len(line)):
904 if (line[ii] == '('):
905 opens += 1;
906 elif (line[ii] == ')'):
907 opens -= 1;
908
909 if (opens == 0):
910 break;
911
912 current += line[0:ii + 1];
913 continue;
914
915 for prefix in prefixes:
916 if (not line.startswith(prefix + '(')):
917 continue;
918
919 if (len(current) > 0):
920 fields.append(parse_field(current));
921 current = '';
922
923 for ii in range(len(prefix), len(line)):
924 if (line[ii] == '('):
925 opens += 1;
926 elif (line[ii] == ')'):
927 opens -= 1;
928
929 if (opens == 0):
930 break;
931
932 current += line[0:ii + 1];
933
934 if (len(current) > 0):
935 fields.append(parse_field(current));
936 current = '';
937
938#

Callers 1

load_fieldsFunction · 0.85

Calls 4

parse_fieldFunction · 0.85
openMethod · 0.65
rangeFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected