Ejemplo n.º 1
0
 public HostBridge(GossipLexer gossipLexer)
 {
     m_HostCallTable = new HostCallTable();
     m_TypeBindingTable = new TypeBindingTable(gossipLexer);
     m_EnumDefineTable = new EnumDefineTable();
     m_ExpressionEvaluator = new ExpressionEvaluator(m_HostCallTable);
     m_EventBindingTable = new EventBindingTable();
 }
Ejemplo n.º 2
0
 public GossipCompiler(GossipVM engine,
                       GossipLexer lexer,
                       ScriptNodeParser scriptNodeParser)
 {
     m_HostCallTable = engine.HostBridge.HostCallTable;
     m_Precompiler = new Precompiler();
     m_Engine = engine;
     m_Lexer = lexer;
     m_ScriptNodeParser = scriptNodeParser;
     m_ExpressionParser = new ExpressionParser();
     m_StateMachineParser = new StateMachineParser();
 }
Ejemplo n.º 3
0
        public GossipVM()
        {
            GlobalState = new GlobalState();

            Lexer = new GossipLexer();
            m_HostBridge = new HostBridge(Lexer);
            Compiler = new GossipCompiler(this, Lexer, new ScriptNodeParser());

            CurrentActiveScripts = new List<CompiledScript>(16);

            // Math
            RegisterGlobalFunction("cos", new Func<double, double>(Math.Cos));
            RegisterGlobalFunction("sin", new Func<double, double>(Math.Sin));
            RegisterGlobalFunction("exp", new Func<double, double>(Math.Exp));
            RegisterGlobalFunction("max", new Func<double, double, double>(Math.Max));
            RegisterGlobalFunction("min", new Func<double, double, double>(Math.Min));

            // System
            RegisterGlobalAction("system", new ActionInfo("Print", Print, null, null));
            RegisterGlobalAction("system", new ActionInfo("Goto", Goto));

            RegisterGlobalFunction("system.rand", new Func<double, double, double>((a, b) => m_Random.Next((Int32) a, (Int32) (b) + 1)));
        }