lib/ProfileIndex.js
function() {

		// Reset index
		this.index = [];

		// Apply extends to the objects
		for (var i=0, l=this._objTree.length; i<l; ++i) {
			if (this.objects[this._objTree[i][0]] === undefined) {
				throw "Extending unknown object "+this._objTree[i][0];
			}

			// Apply
			this.objects[this._objTree[i][1]].applyExtend(
				this.objects[this._objTree[i][0]]
			);
		}

		// Resolve dependencies
		var deps = toposort( this._objTree ).reverse(), used = {};
		for (var i=0, l=deps.length; i<l; ++i) {
			used[deps[i]] = 1;
			this.objects[deps[i]].id = this.index.length;
			this.index.push( this.objects[deps[i]] );
		}

		// Then include objects not part of dependency tree
		for (var i=0, l=this._objList.length; i<l; ++i) {
			// Skip objects already used in the dependency resolution
			if (!used[this._objList[i]])  {
				this.index.push( this.objects[this._objList[i]] );
			}
		}

		// Then pre-cache property IDs for all the propeties
		// and check if any of the objects has embeds
		for (var i=0, l=this.index.length; i<l; ++i) {
			var pp = this.index[i].properties;
			for (var j=0, jl=pp.length; j<jl; ++j) {
				this.propertyVar(pp[j]);
			}
			if (this.index[i].embed.length > 0) {
				this.hasEmbed = true;
			}
		}

		// Separate to frequent and infrequent objects
		for (var i=0, l=this.index.length; i<l; ++i) {
			var obj = this.index[i], isFreq = obj.frequent;

			// Make sure we only register 5-bit objects
			if (isFreq) {
				if (this._objFreq.length >= MAX_FREQ_ITEMS) {
					isFreq = false;
				}
			}

			// Put on frequent or infrequent table
			if (isFreq) {
				obj.id = this._objFreq.length;
				this._objFreq.push(obj);
			} else {
				obj.id = this._objInfeq.length+MAX_FREQ_ITEMS;
				this._objInfeq.push(obj);
			}

		}

	}
function() {

		// Reset index
		this.index = [];

		// Apply extends to the objects
		for (var i=0, l=this._objTree.length; i<l; ++i) {
			if (this.objects[this._objTree[i][0]] === undefined) {
				throw "Extending unknown object "+this._objTree[i][0];
			}

			// Apply
			this.objects[this._objTree[i][1]].applyExtend(
				this.objects[this._objTree[i][0]]
			);
		}

		// Resolve dependencies
		var deps = toposort( this._objTree ).reverse(), used = {};
		for (var i=0, l=deps.length; i<l; ++i) {
			used[deps[i]] = 1;
			this.objects[deps[i]].id = this.index.length;
			this.index.push( this.objects[deps[i]] );
		}

		// Then include objects not part of dependency tree
		for (var i=0, l=this._objList.length; i<l; ++i) {
			// Skip objects already used in the dependency resolution
			if (!used[this._objList[i]])  {
				this.index.push( this.objects[this._objList[i]] );
			}
		}

		// Then pre-cache property IDs for all the propeties
		// and check if any of the objects has embeds
		for (var i=0, l=this.index.length; i<l; ++i) {
			var pp = this.index[i].properties;
			for (var j=0, jl=pp.length; j<jl; ++j) {
				this.propertyVar(pp[j]);
			}
			if (this.index[i].embed.length > 0) {
				this.hasEmbed = true;
			}
		}

		// Separate to frequent and infrequent objects
		for (var i=0, l=this.index.length; i<l; ++i) {
			var obj = this.index[i], isFreq = obj.frequent;

			// Make sure we only register 5-bit objects
			if (isFreq) {
				if (this._objFreq.length >= MAX_FREQ_ITEMS) {
					isFreq = false;
				}
			}

			// Put on frequent or infrequent table
			if (isFreq) {
				obj.id = this._objFreq.length;
				this._objFreq.push(obj);
			} else {
				obj.id = this._objInfeq.length+MAX_FREQ_ITEMS;
				this._objInfeq.push(obj);
			}

		}

	}
function ( ) { // Reset index this . index = [ ] ; // Apply extends to the objects for ( var i = 0 , l = this . _objTree . length ; i < l ; ++ i ) { if ( this . objects [ this . _objTree [ i ] [ 0 ] ] === undefined ) { throw "Extending unknown object " + this . _objTree [ i ] [ 0 ] ; } // Apply this . objects [ this . _objTree [ i ] [ 1 ] ] . applyExtend ( this . objects [ this . _objTree [ i ] [ 0 ] ] ) ; } // Resolve dependencies var deps = toposort ( this . _objTree ) . reverse ( ) , used = { } ; for ( var i = 0 , l = deps . length ; i < l ; ++ i ) { used [ deps [ i ] ] = 1 ; this . objects [ deps [ i ] ] . id = this . index . length ; this . index . push ( this . objects [ deps [ i ] ] ) ; } // Then include objects not part of dependency tree for ( var i = 0 , l = this . _objList . length ; i < l ; ++ i ) { // Skip objects already used in the dependency resolution if ( ! used [ this . _objList [ i ] ] ) { this . index . push ( this . objects [ this . _objList [ i ] ] ) ; } } // Then pre-cache property IDs for all the propeties // and check if any of the objects has embeds for ( var i = 0 , l = this . index . length ; i < l ; ++ i ) { var pp = this . index [ i ] . properties ; for ( var j = 0 , jl = pp . length ; j < jl ; ++ j ) { this . propertyVar ( pp [ j ] ) ; } if ( this . index [ i ] . embed . length > 0 ) { this . hasEmbed = true ; } } // Separate to frequent and infrequent objects for ( var i = 0 , l = this . index . length ; i < l ; ++ i ) { var obj = this . index [ i ] , isFreq = obj . frequent ; // Make sure we only register 5-bit objects if ( isFreq ) { if ( this . _objFreq . length >= MAX_FREQ_ITEMS ) { isFreq = false ; } } // Put on frequent or infrequent table if ( isFreq ) { obj . id = this . _objFreq . length ; this . _objFreq . push ( obj ) ; } else { obj . id = this . _objInfeq . length + MAX_FREQ_ITEMS ; this . _objInfeq . push ( obj ) ; } } }
Resolve dependencies and arrange objects
accoridng to priority and priority.

Also handle subclassing of objects and other elements.
Resolve dependencies and arrange objects accoridng to priority and priority .