Example #1
0
        public override bool Equals(object obj)
        {
            bool result;

            result = obj switch
            {
                StateSymbol s => State.Label == s.Label,
                StateValueNode s => State.Label == s.State.Label,
                            _ => false,
            };

            return(result && base.Equals(obj));
        }
        private void AddIdentifierElement(IdentifierValueNode node, List <ValueNode> values)
        {
            Symbol sym = Stbl.st.Retrieve(node.Label);

            if (sym != null)
            {
                values.Add(sym switch
                {
                    VariableSymbol <int> v => new IntValueNode(v.Value),
                    VariableSymbol <string> v => new StringValueNode(v.Value),
                    VariableSymbol <StateSymbol> v => new StateValueNode(v.Value),
                    StateSymbol s => new StateValueNode(s),
                    _ => throw new TheLanguageErrorException($"Unexpected variable type \"{ sym.GetType().Name }\""),
                });
Example #3
0
        /// <summary>
        ///     Called when the state of this entities script is changed.
        /// </summary>
        /// <param name="process">Process that had its state changed.</param>
        /// <param name="sate">New state.</param>
        public void OnStateChange(ScriptProcess process, StateSymbol state)
        {
            if (_isServer == true)
            {
                return;
            }

            if (_mapScriptProcess != null && process == _mapScriptProcess.Process)
            {
                _window.MapScriptRenderFunction = state.FindSymbol("OnRender", SymbolType.Function) as FunctionSymbol;
            }
            else if (_gameScriptProcess != null && process == _gameScriptProcess.Process)
            {
                _window.GameScriptRenderFunction = state.FindSymbol("OnRender", SymbolType.Function) as FunctionSymbol;
            }
        }
        public void Visit(AdvancedReturnStatementNode node)
        {
            ValueAstEvaluator          valueEvaluator = new ValueAstEvaluator(sender);
            MathExpressionAstEvaluator exprEvaluator  = new MathExpressionAstEvaluator();
            Cell   cell = sender.GetCurrentCell();
            Symbol sym  = Stbl.st.Retrieve(node.Identifier.Label);

            if (sym is StateSymbol s)
            {
                try
                {
                    // Set state members
                    StateSymbol state = s.Copy();
                    foreach (ReturnMemberNode rNode in node.ReturnMembers)
                    {
                        MemberSymbol member = state.RetrieveMember(rNode.ID.Label);
                        switch (rNode.Value)
                        {
                        case ExpressionNode valueNode: member.SetValue(exprEvaluator.Visit(valueNode)); break;

                        case StringValueNode valueNode: member.SetValue(valueNode.Value); break;

                        default: throw new TheLanguageErrorException($"ReturnMember value cannot be of type \'{ rNode.Value.GetType().Name }\'");
                        }
                    }
                    sender.SetCell(cell, state);
                }
                catch (TheLanguageErrorException e) { throw new TheLanguageErrorException($"Return statement \'{ node.Identifier.Label }\'", e); }
            }
            else
            {
                throw new TheLanguageErrorException($"Return statement. Unexpected type { sym } expected State");
            }

            sender.ReturnStatementHasBeenHit = true;
        }
Example #5
0
 /// <summary>
 ///     Called when the state of this entities script is changed.
 /// </summary>
 /// <param name="process">Process that had its state changed.</param>
 /// <param name="sate">New state.</param>
 public void OnStateChange(ScriptProcess process, StateSymbol state)
 {
     _renderFunction = state == null ? null : _process.Process.State.FindSymbol("OnRender", SymbolType.Function) as FunctionSymbol;
     // SyncCollisionEvents();
 }
Example #6
0
 public StateValueNode(StateSymbol state)
 {
     State = state;
 }
Example #7
0
 /// <summary>
 ///     Called when the state of this entities script is changed.
 /// </summary>
 /// <param name="process">Process that had its state changed.</param>
 /// <param name="sate">New state.</param>
 public void OnStateChange(ScriptProcess process, StateSymbol state)
 {
     _tickFunction = (state == null ? null : (state.FindSymbol("OnTick", SymbolType.Function) as FunctionSymbol));
 }