OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # | 3 # |
4 # Copyright 2012 the V8 project authors. All rights reserved. | 4 # Copyright 2012 the V8 project authors. All rights reserved. |
5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
7 # met: | 7 # met: |
8 # | 8 # |
9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 'JSObject, elements, Object, kElementsOffset', | 107 'JSObject, elements, Object, kElementsOffset', |
108 'FixedArray, data, uintptr_t, kHeaderSize', | 108 'FixedArray, data, uintptr_t, kHeaderSize', |
109 'Map, instance_attributes, int, kInstanceAttributesOffset', | 109 'Map, instance_attributes, int, kInstanceAttributesOffset', |
110 'Map, instance_descriptors, int, kInstanceDescriptorsOrBitField3Offset', | 110 'Map, instance_descriptors, int, kInstanceDescriptorsOrBitField3Offset', |
111 'Map, inobject_properties, int, kInObjectPropertiesOffset', | 111 'Map, inobject_properties, int, kInObjectPropertiesOffset', |
112 'Map, instance_size, int, kInstanceSizeOffset', | 112 'Map, instance_size, int, kInstanceSizeOffset', |
113 'HeapNumber, value, double, kValueOffset', | 113 'HeapNumber, value, double, kValueOffset', |
114 'ConsString, first, String, kFirstOffset', | 114 'ConsString, first, String, kFirstOffset', |
115 'ConsString, second, String, kSecondOffset', | 115 'ConsString, second, String, kSecondOffset', |
116 'ExternalString, resource, Object, kResourceOffset', | 116 'ExternalString, resource, Object, kResourceOffset', |
117 'SeqAsciiString, chars, char, kHeaderSize', | 117 'SeqOneByteString, chars, char, kHeaderSize', |
118 'SharedFunctionInfo, code, Code, kCodeOffset', | 118 'SharedFunctionInfo, code, Code, kCodeOffset', |
119 'Code, instruction_start, uintptr_t, kHeaderSize', | 119 'Code, instruction_start, uintptr_t, kHeaderSize', |
120 'Code, instruction_size, int, kInstructionSizeOffset', | 120 'Code, instruction_size, int, kInstructionSizeOffset', |
121 ]; | 121 ]; |
122 | 122 |
123 # | 123 # |
124 # The following is a whitelist of classes we expect to find when scanning the | 124 # The following is a whitelist of classes we expect to find when scanning the |
125 # source code. This list is not exhaustive, but it's still useful to identify | 125 # source code. This list is not exhaustive, but it's still useful to identify |
126 # when this script gets out of sync with the source. See load_objects(). | 126 # when this script gets out of sync with the source. See load_objects(). |
127 # | 127 # |
128 expected_classes = [ | 128 expected_classes = [ |
129 'ConsString', 'FixedArray', 'HeapNumber', 'JSArray', 'JSFunction', | 129 'ConsString', 'FixedArray', 'HeapNumber', 'JSArray', 'JSFunction', |
130 'JSObject', 'JSRegExp', 'JSValue', 'Map', 'Oddball', 'Script', | 130 'JSObject', 'JSRegExp', 'JSValue', 'Map', 'Oddball', 'Script', |
131 'SeqAsciiString', 'SharedFunctionInfo' | 131 'SeqOneByteString', 'SharedFunctionInfo' |
132 ]; | 132 ]; |
133 | 133 |
134 | 134 |
135 # | 135 # |
136 # The following structures store high-level representations of the structures | 136 # The following structures store high-level representations of the structures |
137 # for which we're going to emit descriptive constants. | 137 # for which we're going to emit descriptive constants. |
138 # | 138 # |
139 types = {}; # set of all type names | 139 types = {}; # set of all type names |
140 typeclasses = {}; # maps type names to corresponding class names | 140 typeclasses = {}; # maps type names to corresponding class names |
141 klasses = {}; # known classes, including parents | 141 klasses = {}; # known classes, including parents |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 # representation and encoding and add them if they're not | 286 # representation and encoding and add them if they're not |
287 # present. If that doesn't yield a valid class name, then we | 287 # present. If that doesn't yield a valid class name, then we |
288 # strip out the representation. | 288 # strip out the representation. |
289 # | 289 # |
290 if (cctype.endswith('String')): | 290 if (cctype.endswith('String')): |
291 if (cctype.find('Cons') == -1 and | 291 if (cctype.find('Cons') == -1 and |
292 cctype.find('External') == -1 and | 292 cctype.find('External') == -1 and |
293 cctype.find('Sliced') == -1): | 293 cctype.find('Sliced') == -1): |
294 if (cctype.find('Ascii') != -1): | 294 if (cctype.find('Ascii') != -1): |
295 cctype = re.sub('AsciiString$', | 295 cctype = re.sub('AsciiString$', |
296 'SeqAsciiString', cctype); | 296 'SeqOneByteString', cctype); |
297 else: | 297 else: |
298 cctype = re.sub('String$', | 298 cctype = re.sub('String$', |
299 'SeqString', cctype); | 299 'SeqString', cctype); |
300 | 300 |
301 if (cctype.find('Ascii') == -1): | 301 if (cctype.find('Ascii') == -1): |
302 cctype = re.sub('String$', 'TwoByteString', | 302 cctype = re.sub('String$', 'TwoByteString', |
303 cctype); | 303 cctype); |
304 | 304 |
305 if (not (cctype in klasses)): | 305 if (not (cctype in klasses)): |
306 cctype = re.sub('Ascii', '', cctype); | 306 cctype = re.sub('Ascii', '', cctype); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 472 |
473 out.write(footer); | 473 out.write(footer); |
474 | 474 |
475 if (len(sys.argv) < 4): | 475 if (len(sys.argv) < 4): |
476 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]); | 476 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]); |
477 sys.exit(2); | 477 sys.exit(2); |
478 | 478 |
479 load_objects(); | 479 load_objects(); |
480 load_fields(); | 480 load_fields(); |
481 emit_config(); | 481 emit_config(); |
OLD | NEW |