예제 #1
0
        public override void Emit(SourceBuilder sourceCode)
        {
            // emit initialization with element mapped from unique index
            string tempVariableForUniqueResult = NamesOfEntities.MapByUniqueTemporary(PatternElementName);

            sourceCode.AppendFrontFormat("if({0}==null || !({0} is {1}))",
                                         tempVariableForUniqueResult, IsNode ? "GRGEN_LIBGR.INode" : "GRGEN_LIBGR.IEdge");

            // emit check failed code
            sourceCode.Append("{\n");
            sourceCode.Indent();
            CheckFailedOperations.Emit(sourceCode);
            sourceCode.Unindent();
            sourceCode.AppendFront("}\n");

            // assign the value to the candidate variable, cast it to the variable type
            string typeOfVariableContainingCandidate = "GRGEN_LGSP."
                                                       + (IsNode ? "LGSPNode" : "LGSPEdge");
            string variableContainingCandidate = NamesOfEntities.CandidateVariable(PatternElementName);

            sourceCode.AppendFrontFormat("{0} = ({1}){2};\n",
                                         variableContainingCandidate, typeOfVariableContainingCandidate, tempVariableForUniqueResult);
        }