Beispiel #1
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var action = thread.rs().Action.At(Span);

            action.Invoke(action.Base(), "Push", Location.Line, AstNode2.Evaluate(thread) as Operand);
            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #2
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;

            if (AstNode1 is CharacterNode)
            {
                return((AstNode1.Evaluate(thread) as string) + "->value");
            }
            else if (AstNode1 is ConstantNode)
            {
                return(AstNode1.Evaluate(thread));
            }
            else if (AstNode1 is PronounNode)
            {
                return(String.Format("value_of({0},{1})", Location.Line, AstNode1.Evaluate(thread) as string));
            }
            else if (AstNode1 is BinaryOperatorNode)
            {
                return(string.Format(AstNode1.ToString(), Location.Line, AstNode2.Evaluate(thread) as string, AstNode3.Evaluate(thread) as string));
            }
            else if (AstNode1 is UnaryOperatorNode)
            {
                AstNode1.Evaluate(thread);
                return(string.Format((AstNode1 as UnaryOperatorNode).FormatString, AstNode2.Evaluate(thread) as string));
            }
            else
            {
                // error
            }
            return(this);
        }
Beispiel #3
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;

            tw.Write(format, Location.Line, AstNode2.ToString(thread), AstNode3.ToString(thread));
            return(this);
        }
Beispiel #4
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;

            tw.WriteLine("\tpush({0}, second_person, {1});", Location.Line, AstNode2.ToString(thread));

            return(this);
        }
Beispiel #5
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var action = thread.rs().Action;
            var person = thread.rs().Cast[AstNode1.ToString()];

            action.At(Span).Invoke(action.Base(), "Activate", Location.Line, person);
            AstNode2.Evaluate(thread);
            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #6
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;

            tw.WriteLine();
            tw.WriteLine("\tactivate_character({0}, {1});", Location.Line, AstNode1.ToString(thread));
            AstNode2.Evaluate(thread);
            return(this);
        }
Beispiel #7
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var action = thread.rs().Action.At(Span);

            action.Assign(action.Base().Property("Comp1"), AstNode2.Evaluate(thread) as Operand);
            action.Assign(action.Base().Property("Comp2"), AstNode4.Evaluate(thread) as Operand);
            action.Assign(action.Base().Property("TruthFlag"), AstNode3.Evaluate(thread) as Operand);

            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #8
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;

            tw.WriteLine("\tcomp1 = {0};", AstNode2.ToString(thread));
            tw.WriteLine("\tcomp2 = {0};", AstNode4.ToString(thread));
            tw.WriteLine("\ttruth_flag = {0};", AstNode3.ToString(thread));

            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #9
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var action = thread.rs().Action.At(Span);
            var cast   = thread.rs().Cast;

            if (AstNode1 is CharacterNode)
            {
                return((Operand)cast[String1].Property("Value"));
            }
            else if (AstNode1 is ConstantNode)
            {
                return(AstNode1.Evaluate(thread));
            }
            else if (AstNode1 is PronounNode)
            {
                return(action.Base().Invoke("ValueOf", Location.Line, AstNode1.Evaluate(thread) as Operand));
            }
            else if (AstNode1 is BinaryOperatorNode)
            {
                var operand1 = AstNode2.Evaluate(thread) as Operand;
                var operand2 = AstNode3.Evaluate(thread) as Operand;

                // THis is ugly; I apologize
                var term = Child1.ChildNodes[0].Term.Name;
                if (term == "the difference between")
                {
                    return(operand1 - operand2);
                }
                else if (term == "the product of")
                {
                    return(operand1 * operand2);
                }
                else if (term == "the quotient between")
                {
                    return(operand1 / operand2);
                }
                else if (term == "the remainder of the quotient between")
                {
                    return(operand1 % operand2);
                }
                else if (term == "the sum of")
                {
                    return(operand1 + operand2);
                }
            }
            else if (AstNode1 is UnaryOperatorNode)
            {
                return(action.Base().Invoke(AstNode1.Evaluate(thread) as String, Location.Line, AstNode2.Evaluate(thread) as Operand));
            }
            else
            {
                // error
            }
            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #10
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     if (AstNode1 is NonnegatedComparisonNode)
     {
         return(AstNode1.Evaluate(thread));
     }
     else
     {
         return(!(AstNode2.Evaluate(thread) as Operand));
     }
 }
Beispiel #11
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     if (AstNode1 is PositiveNounNode)
     {
         return("1");
     }
     else
     {
         return(string.Format("2*{0}", AstNode2.Evaluate(thread) as string));
     }
 }
Beispiel #12
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     if (AstNode1 is NegativeNounNode)
     {
         return("(-1)");
     }
     else             // astnode1 is NegativeAdjective or astnode1 is neutralAdjective
     {
         return(string.Format("2*{0}", AstNode2.ToString(thread)));
     }
 }
Beispiel #13
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     if (AstNode1 is NothingNode)
     {
         return("0");
     }
     else              // astNode1 is Article, FirstPErson, SecondPerson, thirdPerson
     {
         return(AstNode2.Evaluate(thread));
     }
 }
Beispiel #14
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     if (AstNode1 is NonnegatedComparisonNode)
     {
         return(AstNode1.Evaluate(thread));
     }
     else
     {
         return(string.Format("!{0}", AstNode2.Evaluate(thread) as string));
     }
 }
Beispiel #15
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     if (AstNode1 is PositiveComparativeNode)
     {
         return(AstNode1.Evaluate(thread) as Operand);
     }
     else
     {
         return(AstNode2.Evaluate(thread) as Operand);
     }
 }
Beispiel #16
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     if (AstNode1 is PositiveNounNode)
     {
         return((Operand)1);
     }
     else // astnode1 is NegativeAdjective or astnode1 is neutralAdjective
     {
         return((AstNode2.Evaluate(thread) as Operand) * 2);
     }
 }
Beispiel #17
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     if (AstNode1 is NegativeComparativeTermNode)
     {
         return(AstNode1.Evaluate(thread));
     }
     else
     {
         return(AstNode2.Evaluate(thread));
     }
 }
Beispiel #18
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            Context.CurrentAct = actnumber;

            var tw = thread.tc().Writer;

            tw.WriteLine();
            tw.Write((Context.CurrentAct + ":").PadRight(Constant.COMMENT_COLUMN));
            tw.WriteLine(AstNode2.ToString(thread));

            return(this);
        }
Beispiel #19
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;

            if (AstNode2 is SceneRomanNode)
            {
                tw.WriteLine("\tgoto {0}_{1};", Context.CurrentAct, AstNode2.ToString().str2varname());
            }
            else
            {
                tw.WriteLine("\tgoto {0};", AstNode2.ToString().str2varname());
            }

            return(this);
        }
Beispiel #20
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            if (AstNode1 is UnconditionalSentenceNode)
            {
                AstNode1.Evaluate(thread);
            }
            else
            {
                var tw = thread.tc().Writer;
                tw.WriteLine("\t\tif({0}) {{", AstNode1.ToString(thread));
                AstNode2.Evaluate(thread);
                tw.WriteLine("\t}");
            }

            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #21
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var term    = AstNode1.Term;
            var strTerm = term != null?term.ToString() : null;

            if (strTerm == "more" || strTerm == "less")
            {
                var st1 = AstNode1.Evaluate(thread) as string;
                var st2 = AstNode2.Evaluate(thread) as string;
                return(st1 + ' ' + st2);
            }
            else
            {
                return(AstNode1.Evaluate(thread));
            }
        }
Beispiel #22
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            if (AstNode1 is UnconditionalSentenceNode)
            {
                AstNode1.Evaluate(thread);
            }
            else
            {
                var action = thread.rs().Action.At(Span);
                action.If(AstNode1.Evaluate(thread) as Operand);
                AstNode2.Evaluate(thread);
                action.End();
            }

            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #23
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            string label;

            if (AstNode2 is SceneRomanNode)
            {
                label = Context.CurrentAct + "_" + AstNode2.ToString(thread).str2varname();
            }
            else
            {
                label = AstNode2.ToString(thread).str2varname();
            }

            thread.rs().Action.At(Span).Goto(label);

            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #24
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            if (AstNode1 is SecondPersonNode)
            {
                var tw = thread.tc().Writer;
                if (AstNode2 is BeNode)
                {
                    if (AstNode3 is ConstantNode)
                    {
                        tw.WriteLine("\t\tAssign({0}, {1});", Location.Line, AstNode3.Evaluate(thread) as string);
                    }
                    else                        // SECOND_PERSON BE Equality Value StatementSymbol
                    {
                        tw.WriteLine("\t\tAssign({0}, {1});", Location.Line, AstNode4.Evaluate(thread) as string);
                    }
                }
                else if (AstNode2 is UnarticulatedConstantNode)
                {
                    tw.WriteLine("\t\tAssign({0}, {1});", Location.Line, AstNode2.Evaluate(thread) as string);
                }
            }

            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #25
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            if (AstNode1 is SecondPersonNode)
            {
                var action = thread.rs().Action.At(Span);
                if (AstNode2 is BeNode)
                {
                    if (AstNode3 is ConstantNode)
                    {
                        action.Invoke(action.Base(), "Assign", Location.Line, AstNode3.Evaluate(thread) as Operand);
                    }
                    else    // SECOND_PERSON BE Equality Value StatementSymbol
                    {
                        action.Invoke(action.Base(), "Assign", Location.Line, AstNode4.Evaluate(thread) as Operand);
                    }
                }
                else if (AstNode2 is UnarticulatedConstantNode)
                {
                    action.Invoke(action.Base(), "Assign", Location.Line, AstNode2.Evaluate(thread) as Operand);
                }
            }

            return(base.ReallyDoEvaluate(thread));
        }
Beispiel #26
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;

            tw.WriteLine("\t\tCharacter\t{0} = InitializeCharacter({2},\"{0}\");\t\t{1}", AstNode1.ToString(thread), AstNode2.ToString(thread), Location.Line);
            return(this);
        }
Beispiel #27
0
 protected override object ReallyDoEvaluate(Irony.Interpreter.ScriptThread thread)
 {
     AstNode1.Evaluate(thread);
     AstNode2.Evaluate(thread);
     return(base.ReallyDoEvaluate(thread));
 }
Beispiel #28
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var tw = thread.tc().Writer;

            Context.CurrentScene = Context.CurrentAct + "_" + scenenumber;
            tw.WriteLine("{0}{1}", (Context.CurrentScene + ":").PadRight(Constant.COMMENT_COLUMN), AstNode2.ToString(thread));
            return(this);
        }