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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 # | 54 # |
55 consts_misc = [ | 55 consts_misc = [ |
56 { 'name': 'FirstNonstringType', 'value': 'FIRST_NONSTRING_TYPE' }, | 56 { 'name': 'FirstNonstringType', 'value': 'FIRST_NONSTRING_TYPE' }, |
57 | 57 |
58 { 'name': 'IsNotStringMask', 'value': 'kIsNotStringMask' }, | 58 { 'name': 'IsNotStringMask', 'value': 'kIsNotStringMask' }, |
59 { 'name': 'StringTag', 'value': 'kStringTag' }, | 59 { 'name': 'StringTag', 'value': 'kStringTag' }, |
60 { 'name': 'NotStringTag', 'value': 'kNotStringTag' }, | 60 { 'name': 'NotStringTag', 'value': 'kNotStringTag' }, |
61 | 61 |
62 { 'name': 'StringEncodingMask', 'value': 'kStringEncodingMask' }, | 62 { 'name': 'StringEncodingMask', 'value': 'kStringEncodingMask' }, |
63 { 'name': 'TwoByteStringTag', 'value': 'kTwoByteStringTag' }, | 63 { 'name': 'TwoByteStringTag', 'value': 'kTwoByteStringTag' }, |
64 { 'name': 'AsciiStringTag', 'value': 'kOneByteStringTag' }, | 64 { 'name': 'OneByteStringTag', 'value': 'kOneByteStringTag' }, |
65 | 65 |
66 { 'name': 'StringRepresentationMask', | 66 { 'name': 'StringRepresentationMask', |
67 'value': 'kStringRepresentationMask' }, | 67 'value': 'kStringRepresentationMask' }, |
68 { 'name': 'SeqStringTag', 'value': 'kSeqStringTag' }, | 68 { 'name': 'SeqStringTag', 'value': 'kSeqStringTag' }, |
69 { 'name': 'ConsStringTag', 'value': 'kConsStringTag' }, | 69 { 'name': 'ConsStringTag', 'value': 'kConsStringTag' }, |
70 { 'name': 'ExternalStringTag', 'value': 'kExternalStringTag' }, | 70 { 'name': 'ExternalStringTag', 'value': 'kExternalStringTag' }, |
71 { 'name': 'SlicedStringTag', 'value': 'kSlicedStringTag' }, | 71 { 'name': 'SlicedStringTag', 'value': 'kSlicedStringTag' }, |
72 | 72 |
73 { 'name': 'FailureTag', 'value': 'kFailureTag' }, | 73 { 'name': 'FailureTag', 'value': 'kFailureTag' }, |
74 { 'name': 'FailureTagMask', 'value': 'kFailureTagMask' }, | 74 { 'name': 'FailureTagMask', 'value': 'kFailureTagMask' }, |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 cctype = ''; | 308 cctype = ''; |
309 start = 0; | 309 start = 0; |
310 | 310 |
311 for ii in range(start, len(parts)): | 311 for ii in range(start, len(parts)): |
312 part = parts[ii]; | 312 part = parts[ii]; |
313 cctype += part[0].upper() + part[1:].lower(); | 313 cctype += part[0].upper() + part[1:].lower(); |
314 | 314 |
315 # | 315 # |
316 # Mapping string types is more complicated. Both types and | 316 # Mapping string types is more complicated. Both types and |
317 # class names for Strings specify a representation (e.g., Seq, | 317 # class names for Strings specify a representation (e.g., Seq, |
318 # Cons, External, or Sliced) and an encoding (TwoByte or Ascii), | 318 # Cons, External, or Sliced) and an encoding (TwoByte/OneByte), |
319 # In the simplest case, both of these are explicit in both | 319 # In the simplest case, both of these are explicit in both |
320 # names, as in: | 320 # names, as in: |
321 # | 321 # |
322 # EXTERNAL_ASCII_STRING_TYPE => ExternalAsciiString | 322 # EXTERNAL_ONE_BYTE_STRING_TYPE => ExternalOneByteString |
323 # | 323 # |
324 # However, either the representation or encoding can be omitted | 324 # However, either the representation or encoding can be omitted |
325 # from the type name, in which case "Seq" and "TwoByte" are | 325 # from the type name, in which case "Seq" and "TwoByte" are |
326 # assumed, as in: | 326 # assumed, as in: |
327 # | 327 # |
328 # STRING_TYPE => SeqTwoByteString | 328 # STRING_TYPE => SeqTwoByteString |
329 # | 329 # |
330 # Additionally, sometimes the type name has more information | 330 # Additionally, sometimes the type name has more information |
331 # than the class, as in: | 331 # than the class, as in: |
332 # | 332 # |
333 # CONS_ASCII_STRING_TYPE => ConsString | 333 # CONS_ONE_BYTE_STRING_TYPE => ConsString |
334 # | 334 # |
335 # To figure this out dynamically, we first check for a | 335 # To figure this out dynamically, we first check for a |
336 # representation and encoding and add them if they're not | 336 # representation and encoding and add them if they're not |
337 # present. If that doesn't yield a valid class name, then we | 337 # present. If that doesn't yield a valid class name, then we |
338 # strip out the representation. | 338 # strip out the representation. |
339 # | 339 # |
340 if (cctype.endswith('String')): | 340 if (cctype.endswith('String')): |
341 if (cctype.find('Cons') == -1 and | 341 if (cctype.find('Cons') == -1 and |
342 cctype.find('External') == -1 and | 342 cctype.find('External') == -1 and |
343 cctype.find('Sliced') == -1): | 343 cctype.find('Sliced') == -1): |
344 if (cctype.find('Ascii') != -1): | 344 if (cctype.find('OneByte') != -1): |
345 cctype = re.sub('AsciiString$', | 345 cctype = re.sub('OneByteString$', |
346 'SeqOneByteString', cctype); | 346 'SeqOneByteString', cctype); |
347 else: | 347 else: |
348 cctype = re.sub('String$', | 348 cctype = re.sub('String$', |
349 'SeqString', cctype); | 349 'SeqString', cctype); |
350 | 350 |
351 if (cctype.find('Ascii') == -1): | 351 if (cctype.find('OneByte') == -1): |
352 cctype = re.sub('String$', 'TwoByteString', | 352 cctype = re.sub('String$', 'TwoByteString', |
353 cctype); | 353 cctype); |
354 | 354 |
355 if (not (cctype in klasses)): | 355 if (not (cctype in klasses)): |
356 cctype = re.sub('Ascii', '', cctype); | 356 cctype = re.sub('OneByte', '', cctype); |
357 cctype = re.sub('TwoByte', '', cctype); | 357 cctype = re.sub('TwoByte', '', cctype); |
358 | 358 |
359 # | 359 # |
360 # Despite all that, some types have no corresponding class. | 360 # Despite all that, some types have no corresponding class. |
361 # | 361 # |
362 if (cctype in klasses): | 362 if (cctype in klasses): |
363 typeclasses[type] = cctype; | 363 typeclasses[type] = cctype; |
364 if (cctype in checktypes): | 364 if (cctype in checktypes): |
365 del checktypes[cctype]; | 365 del checktypes[cctype]; |
366 | 366 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 527 |
528 out.write(footer); | 528 out.write(footer); |
529 | 529 |
530 if (len(sys.argv) < 4): | 530 if (len(sys.argv) < 4): |
531 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]); | 531 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]); |
532 sys.exit(2); | 532 sys.exit(2); |
533 | 533 |
534 load_objects(); | 534 load_objects(); |
535 load_fields(); | 535 load_fields(); |
536 emit_config(); | 536 emit_config(); |
OLD | NEW |