refactor label handling into AsyncEmbeddedScript
This commit is contained in:
@@ -4,36 +4,19 @@
|
||||
(collectBlocks preload (#when (StringTools.contains kissFile className) (cc)))
|
||||
(collectBlocks cleanup (#when (StringTools.contains kissFile className) (cc)))
|
||||
|
||||
(prop :Map<String,Int> labelsByName (new Map))
|
||||
(prop :Array<Int> labels [])
|
||||
|
||||
(defMacroVar _labelNames [])
|
||||
(defMacroVar _labelLines [])
|
||||
(defReaderMacro "LABEL " [stream]
|
||||
(_labelNames.push (stream.expect "label name" ->(stream.takeLine)))
|
||||
(_labelLines.push (- .line (stream.position) 1))
|
||||
`(cc))
|
||||
|
||||
(defMacro end []
|
||||
(let [labelSetters
|
||||
(for [label idx] (zipThrow _labelNames _labelLines)
|
||||
`{
|
||||
(dictSet labelsByName ,label ,idx)
|
||||
(labels.push ,idx)
|
||||
})]
|
||||
`{
|
||||
(method doPreload [:Void->Void cc]
|
||||
(set isLoading true)
|
||||
(collectedBlocks preload)
|
||||
(set isLoading false)
|
||||
,@labelSetters
|
||||
(cc))
|
||||
(method doCleanup []
|
||||
(director.cleanup)
|
||||
(set lastInstructionPointer -2)
|
||||
(collectedBlocks cleanup))
|
||||
(doCleanup)
|
||||
}))
|
||||
`{
|
||||
(method doPreload [:Void->Void cc]
|
||||
(set isLoading true)
|
||||
(collectedBlocks preload)
|
||||
(set isLoading false)
|
||||
(cc))
|
||||
(method doCleanup []
|
||||
(director.cleanup)
|
||||
(set lastInstructionPointer -2)
|
||||
(collectedBlocks cleanup))
|
||||
(doCleanup)
|
||||
})
|
||||
|
||||
(defReaderMacro &bof "" [stream] `(#when (StringTools.contains kissFile className) (doPreload cc)))
|
||||
(defReaderMacro &eof "" [stream] `(#when (StringTools.contains kissFile className) (end)))
|
||||
Reference in New Issue
Block a user