예제 #1
0
 /// <summary> Object Literals
 /// <BR> CreateObjectLiteral rewrites its argument as object
 /// creation plus object property entries, so later compiler
 /// stages don't need to know about object literals.
 /// </summary>
 internal Node CreateObjectLiteral(ObjArray elems)
 {
     int size = elems.size () / 2;
     Node obj = new Node (Token.OBJECTLIT);
     object [] properties;
     if (size == 0) {
         properties = ScriptRuntime.EmptyArgs;
     }
     else {
         properties = new object [size];
         for (int i = 0; i != size; ++i) {
             properties [i] = elems.Get (2 * i);
             Node value = (Node)elems.Get (2 * i + 1);
             obj.addChildToBack (value);
         }
     }
     obj.putProp (Node.OBJECT_IDS_PROP, properties);
     return obj;
 }
예제 #2
0
 internal Node CreateArrayLiteral(ObjArray elems, int skipCount)
 {
     int length = elems.size ();
     int [] skipIndexes = null;
     if (skipCount != 0) {
         skipIndexes = new int [skipCount];
     }
     Node array = new Node (Token.ARRAYLIT);
     for (int i = 0, j = 0; i != length; ++i) {
         Node elem = (Node)elems.Get (i);
         if (elem != null) {
             array.addChildToBack (elem);
         }
         else {
             skipIndexes [j] = i;
             ++j;
         }
     }
     if (skipCount != 0) {
         array.putProp (Node.SKIP_INDEXES_PROP, skipIndexes);
     }
     return array;
 }