Beispiel #1
0
        public void CompileBlock(Block block)
        {
            textWriter.WriteLine("{");
            ++textWriter.Indentation;

            bool wasFunctionBody = inFunctionBody;

            inFunctionBody = false;
            bool wasBlockInline = isBlockInline;

            isBlockInline = false;

            int counter = 0;
            int length  = block.Statements.Length;

            if (wasFunctionBody)
            {
                --length;
            }

            while (counter < length)
            {
                if (block.Statements[counter] is ParentConstructorCall)
                {
                    ++counter;
                    continue;
                }

                foreach (var pair in block.Labels)
                {
                    if (pair.Value.Address == counter)
                    {
                        textWriter.WriteLine("{0}:", SafeName(pair.Key));
                    }
                }

                Statement stmt = block.Statements[counter];
                stmt.AcceptCompiler(this);
                if (stmt is Expression)
                {
                    textWriter.WriteLine(";");
                }
                ++counter;
            }

            --textWriter.Indentation;
            textWriter.Write("}");
            if (!wasBlockInline)
            {
                textWriter.WriteLine();
            }

            isBlockInline  = wasBlockInline;
            inFunctionBody = wasFunctionBody;
        }