/* static */ void VJSONGraph::ReleaseArrayDependenciesIfNecessary( VJSONArray *inArray) { std::vector<VJSONObject*> objects; std::vector<VJSONArray*> arrays; sLONG referencesTotal = 0; bool cyclic = false; CollectArrayReferences( inArray, objects, arrays, referencesTotal, &cyclic); if (cyclic) { ReleaseDependenciesIfNecessary( inArray, objects, arrays, referencesTotal); } }
void ScalarReplacementPass2::do_procedure_definition(ProcedureDefinition* p) { procDef = p ; assert(procDef != NULL) ; OutputInformation("Scalar replacement pass 2.0 begins") ; VerifyArrayReferences() ; CollectArrayReferences() ; ProcessLoads() ; ProcessStores() ; PrependLoads() ; AppendStores() ; OutputInformation("Scalar replacement pass 2.0 ends") ; }
/* static */ void VJSONGraph::CollectObjectReferences( VJSONObject *inObject, std::vector<VJSONObject*>& ioObjects, std::vector<VJSONArray*>& ioArrays, sLONG& ioReferencesTotal, bool *outCyclic) { ioReferencesTotal += 1; if (std::find( ioObjects.begin(), ioObjects.end(), inObject) == ioObjects.end()) { ioObjects.push_back( inObject); for( VJSONPropertyConstIterator i( inObject) ; i.IsValid() ; ++i) { const VJSONValue& value = i.GetValue(); if (value.IsObject()) CollectObjectReferences( value.GetObject(), ioObjects, ioArrays, ioReferencesTotal, outCyclic); else if (value.IsArray()) CollectArrayReferences( value.GetArray(), ioObjects, ioArrays, ioReferencesTotal, outCyclic); } } else { *outCyclic = true; } }
/* static */ void VJSONGraph::CollectArrayReferences( VJSONArray *inArray, std::vector<VJSONObject*>& ioObjects, std::vector<VJSONArray*>& ioArrays, sLONG& ioReferencesTotal, bool *outCyclic) { ioReferencesTotal += 1; if (std::find( ioArrays.begin(), ioArrays.end(), inArray) == ioArrays.end()) { ioArrays.push_back( inArray); size_t count = inArray->GetCount(); for( size_t i = 0 ; i < count ; ++i) { const VJSONValue& value = (*inArray)[i]; if (value.IsObject()) CollectObjectReferences( value.GetObject(), ioObjects, ioArrays, ioReferencesTotal, outCyclic); else if (value.IsArray()) CollectArrayReferences( value.GetArray(), ioObjects, ioArrays, ioReferencesTotal, outCyclic); } } else { *outCyclic = true; } }