! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: namespaces make math math.parser sequences accessors kernel kernel.private layouts assocs words summary arrays threads continuations.private libc combinators alien alien.c-types alien.structs alien.strings compiler.errors compiler.alien compiler.backend compiler.codegen.fixup compiler.cfg compiler.cfg.instructions compiler.cfg.registers ; IN: compiler.codegen GENERIC: generate-insn ( insn -- ) : generate-insns ( insns -- code ) [ [ dup regs>> registers set generate-insn ] each ] { } make fixup ; TUPLE: asm label code calls ; SYMBOL: calls : add-call ( word -- ) #! Compile this word later. calls get push ; SYMBOL: compiling-word : compiled-stack-traces? ( -- ? ) 59 getenv ; ! Mapping _label IDs to label instances SYMBOL: labels : init-generator ( word -- ) H{ } clone labels set V{ } clone literal-table set V{ } clone calls set compiling-word set compiled-stack-traces? compiling-word get f ? add-literal drop ; : generate ( mr -- asm ) [ [ label>> ] [ word>> init-generator ] [ instructions>> generate-insns ] tri calls get asm boa ] with-scope ; : lookup-label ( id -- label ) labels get [ drop