@@ -1463,12 +1463,24 @@ struct JSPrinter {
14631463 newline ();
14641464 }
14651465 bool needQuote = false ;
1466+ const char * getterSetter = nullptr ;
1467+ const char * setterParam = nullptr ;
14661468 const char * str;
14671469 if (args[i][0 ]->isArray ()) {
1468- assert (args[i][0 ][0 ] == STRING);
1469- // A quoted string.
1470- needQuote = true ;
1471- str = args[i][0 ][1 ]->getCString ();
1470+ if (args[i][0 ][0 ] == STRING) {
1471+ // A quoted string.
1472+ needQuote = true ;
1473+ str = args[i][0 ][1 ]->getCString ();
1474+ } else if (args[i][0 ][0 ] == GETTER) {
1475+ getterSetter = GETTER.c_str ();
1476+ str = args[i][0 ][1 ]->getCString ();
1477+ } else if (args[i][0 ][0 ] == SETTER) {
1478+ getterSetter = SETTER.c_str ();
1479+ str = args[i][0 ][1 ]->getCString ();
1480+ setterParam = args[i][0 ][2 ]->getCString ();
1481+ } else {
1482+ abort ();
1483+ }
14721484 } else {
14731485 // Just a raw string, no quotes.
14741486 str = args[i][0 ]->getCString ();
@@ -1481,14 +1493,26 @@ struct JSPrinter {
14811493 }
14821494 check++;
14831495 }
1496+ if (getterSetter != nullptr ) {
1497+ emit (getterSetter);
1498+ space ();
1499+ }
14841500 if (needQuote) {
14851501 emit (' "' );
14861502 }
14871503 emit (str);
14881504 if (needQuote) {
14891505 emit (' "' );
14901506 }
1491- emit (" :" );
1507+ if (getterSetter != nullptr ) {
1508+ emit (' (' );
1509+ if (setterParam != nullptr ) {
1510+ emit (setterParam);
1511+ }
1512+ emit (' )' );
1513+ } else {
1514+ emit (" :" );
1515+ }
14921516 space ();
14931517 print (args[i][1 ]);
14941518 }
@@ -1828,6 +1852,26 @@ class ValueBuilder {
18281852 &makeRawArray (2 )->push_back (makeString (key)).push_back (value));
18291853 }
18301854
1855+ static void appendToObjectAsGetter (Ref array, IString key, Ref value) {
1856+ assert (array[0 ] == OBJECT);
1857+ array[1 ]->push_back (&makeRawArray (2 )
1858+ ->push_back (&makeRawArray (2 )
1859+ ->push_back (makeRawString (GETTER))
1860+ .push_back (makeRawString (key)))
1861+ .push_back (value));
1862+ }
1863+
1864+ static void
1865+ appendToObjectAsSetter (Ref array, IString key, IString param, Ref value) {
1866+ assert (array[0 ] == OBJECT);
1867+ array[1 ]->push_back (&makeRawArray (2 )
1868+ ->push_back (&makeRawArray (3 )
1869+ ->push_back (makeRawString (SETTER))
1870+ .push_back (makeRawString (key))
1871+ .push_back (makeRawString (param)))
1872+ .push_back (value));
1873+ }
1874+
18311875 static Ref makeSub (Ref obj, Ref index) {
18321876 return &makeRawArray (2 )
18331877 ->push_back (makeRawString (SUB))
0 commit comments