Exemplo n.º 1
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            Context.CurrentAct = actnumber;
            thread.rs().Action.At(Span).Label(actnumber);

            return base.ReallyDoEvaluate(thread);
        }
Exemplo n.º 2
0
        protected override object ReallyDoEvaluate(Irony.Interpreter.ScriptThread thread)
        {
            var rs = thread.rs();
            var ag = rs.AG;

            using (ag.Namespace("Shakespeare.Program"))
            {
                TypeGen scriptClass = ag.Public.Class("Script", typeof(Shakespeare.Support.Dramaturge));
                {
                    rs.Script = scriptClass;

                    var console = typeof(Console);

                    CodeGen ctor = scriptClass.Public.Constructor();
                    ctor.InvokeBase(Static.Property(console, "In"), Static.Property(console, "Out"));
                    {
                    }

                    CodeGen action = scriptClass.Public.Void("Action");
                    {
                        rs.Action = action;
                        action.At(Span);
                        AstNode1.Evaluate(thread);
                        var cdl = AstNode2 as CharacterDeclarationListNode;
                        foreach (var ch in cdl.Characters)
                        {
                            ch.Evaluate(thread);
                        }

                        AstNode3.Evaluate(thread);
                    }
                }
                scriptClass.Complete();

                TypeGen MyClass = ag.Public.Class("Program");
                CodeGen Main    = MyClass.Public.Static.Void("Main").Parameter <string[]>("args");
                {
                    var script = Main.Local(Exp.New(scriptClass.GetCompletedType()));
                    Main.Invoke(script, "Action");
                }
            }
            ag.Save();

            return(ag.GetAssembly().GetName().Name);
        }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var action = thread.rs().Action.At(Span);
     action.Invoke(action.Base(), "Pop",Location.Line);
     return base.ReallyDoEvaluate(thread);
 }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var action = thread.rs().Action.At(Span);

            if (AstNode1 is FirstPersonNode || AstNode1 is FirstPersonReflexiveNode)
                return  action.Base().Property("FirstPerson");
            else if (AstNode1 is SecondPersonNode || AstNode1 is SecondPersonReflexiveNode)
                return  action.Base().Property("SecondPerson");
            return base.ReallyDoEvaluate(thread);
        }
Exemplo n.º 7
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var action = thread.rs().Action.At(Span);
     var name = AstNode1.ToString(thread);
     action[name] = action.Base().Invoke("InitializeCharacter", Location.Line, name);
     thread.rs().Cast.Add(name, action[name]);
     return base.ReallyDoEvaluate(thread);
 }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var action = thread.rs().Action.At(Span);
     if (AstNode1 is OpenYourNode)
     {
         if (String2 == "heart (Keyword)")
         {
             action.Invoke(action.Base(), "IntOutput", Location.Line);
         }
         else  // Open Your Mind
         {
             action.Invoke(action.Base(), "CharInput", Location.Line);
         }
     }
     else if (String1 == "speak")
     {
         action.Invoke(action.Base(), "CharOutput", Location.Line);
     }
     else if (String1 == "listen to")
     {
         action.Invoke(action.Base(), "IntInput", Location.Line);
     }
     return base.ReallyDoEvaluate(thread);
 }
Exemplo n.º 10
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            var action = thread.rs().Action.At(Span);
            var charList = new List<CharacterNode>();
            var cast = thread.rs().Cast;

            if (Exist1)
            {
                if (AstNode1 is CharacterNode)
                    charList.Add(AstNode1 as CharacterNode);
                else
                    (AstNode1 as CharacterListNode).Fill(charList);

                foreach (var chr in charList)
                {
                    var name =  chr.ToString();
                    var person = cast[name];
                    action.Invoke(action.Base(), "ExitScene", Location.Line, person);
                    Context.ActiveCharacters.Remove(chr);
                }
            }
            else
            {
                action.Invoke(action.Base(),"ExitSceneAll", Location.Line);
                Context.ActiveCharacters.Clear();
            }

            return base.ReallyDoEvaluate(thread);
        }
Exemplo n.º 11
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var action = thread.rs().Action.At(Span);
     var cond = action.Base().Property("Comp1") == action.Base().Property("Comp2");
     return cond;
 }
Exemplo n.º 12
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var cn = TreeNode.ChildNodes;
     if (Child1.AstNode is CharacterListNode)
         cn = Child1.ChildNodes;
     var action = thread.rs().Action;
     foreach (var ch in cn)
     {
         var name = ch.AstNode.ToString();
         var person = thread.rs().Cast[name];
         action.At(Span).Invoke(action.Base(), "EnterScene", Location.Line, person);
         Context.ActiveCharacters.Add(ch.AstNode as CharacterNode);
     }
     return base.ReallyDoEvaluate(thread);
 }
Exemplo n.º 13
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var action = thread.rs().Action.At(Span);
     if (Child1.Term.Name == "if so")
         return action.Base().Property("TruthFlag");
     else// if not
         return !action.Base().Property("TruthFlag");
 }
Exemplo n.º 14
0
 protected override object ReallyDoEvaluate(ScriptThread thread)
 {
     var action = thread.rs().Action.At(Span);
     if (AstNode1 is NegativeComparativeNode)
         return action.Base().Property("Comp1") < action.Base().Property("Comp2");
     else  // PositiveComparativeNode
         return action.Base().Property("Comp1") > action.Base().Property("Comp2");
 }
Exemplo n.º 15
0
        protected override object ReallyDoEvaluate(ScriptThread thread)
        {
            Context.CurrentScene = Context.CurrentAct + "_" + scenenumber;

            thread.rs().Action.At(Span).Label(Context.CurrentScene);
            return base.ReallyDoEvaluate(thread);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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);
 }