MCPcopy Create free account
hub / github.com/breck7/scroll / getAtomArray

Method getAtomArray

external/.scrollLibs.js:19284–19309  ·  view source on GitHub ↗
(particle = undefined)

Source from the content-addressed store, hash-verified

19282 return atomIndex >= numberOfRequiredAtoms
19283 }
19284 getAtomArray(particle = undefined) {
19285 const atomCount = particle ? particle.atoms.length : 0
19286 const def = this._definition
19287 const parsersProgram = def.languageDefinitionProgram
19288 const requiredAtomTypeIds = this.getRequiredAtomTypeIds()
19289 const numberOfRequiredAtoms = requiredAtomTypeIds.length
19290 const actualAtomCountOrRequiredAtomCount = Math.max(atomCount, numberOfRequiredAtoms)
19291 const atoms = []
19292 // A for loop instead of map because "numberOfAtomsToFill" can be longer than atoms.length
19293 for (let atomIndex = 0; atomIndex < actualAtomCountOrRequiredAtomCount; atomIndex++) {
19294 const isCatchAll = this._isCatchAllAtom(atomIndex, numberOfRequiredAtoms, atomCount)
19295 let atomTypeId = isCatchAll ? this.catchAllAtomTypeId : this._getAtomTypeId(atomIndex, requiredAtomTypeIds, atomCount)
19296 let atomTypeDefinition = parsersProgram.getAtomTypeDefinitionById(atomTypeId)
19297 let atomConstructor
19298 if (atomTypeDefinition) atomConstructor = atomTypeDefinition.getAtomConstructor()
19299 else if (atomTypeId) atomConstructor = ParsersUnknownAtomTypeAtom
19300 else {
19301 atomConstructor = ParsersExtraAtomAtomTypeAtom
19302 atomTypeId = PreludeAtomTypeIds.extraAtomAtom
19303 atomTypeDefinition = parsersProgram.getAtomTypeDefinitionById(atomTypeId)
19304 }
19305 const anyAtomConstructor = atomConstructor
19306 atoms[atomIndex] = new anyAtomConstructor(particle, atomIndex, atomTypeDefinition, atomTypeId, isCatchAll, def)
19307 }
19308 return atoms
19309 }
19310}
19311class PrefixAtomParser extends AbstractAtomParser {}
19312class PostfixAtomParser extends AbstractAtomParser {

Callers

nothing calls this directly

Calls 6

_isCatchAllAtomMethod · 0.95
_getAtomTypeIdMethod · 0.95
maxMethod · 0.80
getAtomConstructorMethod · 0.80

Tested by

no test coverage detected