Beispiel #1
0
    static void CodeGeneration()
    {
        // create file
        CodeGen codegen = new Flash();

        codegen.Begin("complish");
        codegen.WriteStringTable(literalStrings);

        foreach (multimethod method in multimethods)
        {
            if (method.parsed_body == null || method.parsed_body.Count == 0)
            {   // it's data not code
                parameter subject = null;
                fiveforms verb    = null;
                foreach (term term in method.signature)
                {
                    if (term.which == PartsOfSpeech.verb)
                    {
                        verb = term.verb;
                        break;
                    }
                    else if (term.which == PartsOfSpeech.noun)
                    {
                        subject = term.noun;
                    }
                }
                if (verb == null)
                {
                    continue;
                }
                bool subjectNamesStruct = (verb == TheVerbIs);
                if (subjectNamesStruct && subject == null)
                {
                    continue;//compiler error? named instance? global var?
                }
                //Console.WriteLine("struct {0} {1}  // #{2}{3}", subjectNamesStruct ? subject.fullname1.Replace(' ', '_') : verb.singular + "_relation", "{", method.prompt, method.problems > 0 ? " ?" : "");
                foreach (term term in method.signature)
                {
                    if (term.which != PartsOfSpeech.noun)
                    {
                        continue;
                    }
                    if (subjectNamesStruct && term.noun == subject)
                    {
                        continue;
                    }

                    /*if (term.noun.art != Article.many)
                     *  Console.WriteLine("\t{0} {1};", NameOfType(term.noun.type), term.noun.fullname1.Replace(' ', '_'));
                     * else
                     *  Console.WriteLine("\tList<{0}> {1};", NameOfType(term.noun.type), term.noun.fullname1.Replace(' ', '_'));*/
                }
                //Console.WriteLine("}");
                //Console.WriteLine();
            }
            else // it's code not data
            {
                ;// Console.WriteLine("#{0} called from {1} places", method.prompt, method.called);
            }
        }

        codegen.WriteInt(10);
        codegen.Finish();

        Console.Write("---- press enter ----");
        Console.ReadLine();
    }