<commit_before>
type Context <: Compose3DNode
	box :: BoundingBox #Parent box.
	children :: List{Compose3DNode}
end

Context(x0::Length,y0::Length,z0::Length,width::Length,height::Length,depth::Length) = Context(BoundingBox(x0,y0,z0,width,height,depth),ListNull{Compose3DNode}())

Context(ctx::Context) = Context(ctx.box,ctx.children)

function draw(backend::Backend, root_canvas::Context)
    # TODO: Traverse the tree in DFS manner. And generate JS code to render stuff. \
    # Also use the resolve method to convert relative measures to absolute ones.
    # Hack try for now.
    children = root_canvas.children
    parent_box = root_canvas.box
    #Assert if parent box has absolute values.
    for child in children
    	if isa(child,Geometry)
    		for primitive in child.primitives
    			backend = draw(backend,parent_box,primitive)
    		end
    	end
    	if isa(child, Context)
    		child = Context(resolve(parent_box,child.box),child.children)
    		backend = draw(backend,child)
    	end
    end
    return backend
end

function copy(ctx::Context)
    return Context(ctx)
end

#Compositions.

function compose!(a::Context, b::Compose3DNode)
    a.children = cons(b, a.children)
    return a
end


function compose(a::Context, b::Compose3DNode)
    a = copy(a)<commit_msg>Materials in traversing the compose tree<commit_after>
type Context <: Compose3DNode
	box :: BoundingBox #Parent box.
	children :: List{Compose3DNode}
end

Context(x0::Length,y0::Length,z0::Length,width::Length,height::Length,depth::Length) = Context(BoundingBox(x0,y0,z0,width,height,depth),ListNull{Compose3DNode}())

Context(ctx::Context) = Context(ctx.box,ctx.children)

function draw(backend::Backend, root_canvas::Context)
    # Does a DFS traversal of the compose tree.
    # Checks for contexts, and geometries and resolves and draws them as needed.
    children = root_canvas.children
    parent_box = root_canvas.box
    @assert isa(parent_box, AbsoluteBox)

    for child in children
        if isa(child,Material)
            push_material_frame(backend, child)
        end
    end

    for child in children
    	if isa(child,Geometry)
    		for primitive in child.primitives
    			backend = draw(backend,parent_box,primitive)
    		end
    	end
    	if isa(child, Context)
    		child = Context(resolve(parent_box,child.box),child.children)
    		backend = draw(backend,child)
    	end
    end
    return backend
end

function copy(ctx::Context)
    return Context(ctx)
end

#Compositions.

function compose!(a::Context, b::Compose3DNode)
    a.children = cons(b, a.children)
    return a
end


function compose(a::Context, b::Compose3DNode)
    a = copy(a)
{'fraction_non_alphanumeric': 0.10387655250282274, 'fraction_numerical': 0.008280015054572827, 'mean_word_length': 4.0150943396226415, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2308493', 'n_tokens_mistral': 886, 'n_tokens_neox': 862, 'n_words': 210}