コード例 #1
0
        public IExpression Apply(IVariable variable, IExpression[] index, DocRange variableRange)
        {
            // Callable
            if (variable is ICallable callable)
            {
                Call(callable, variableRange);
            }

            // IIndexReferencers are wrapped by CallVariableActions.
            if (variable is IIndexReferencer referencer)
            {
                // If the type of the variable being called is Player, check if the variable is calling Event Player.
                // If the source expression is null, Event Player is used by default.
                // Otherwise, confirm that the source expression is returning the player variable scope.
                if (referencer.VariableType == VariableType.Player)
                {
                    EventPlayerRestrictedCall(new RestrictedCall(RestrictedCallType.EventPlayer, _parseInfo.GetLocation(variableRange), RestrictedCall.Message_EventPlayerDefault(referencer.Name)));
                }

                // If there is a local variable tracker and the variable requires capture.
                if (referencer.RequiresCapture)
                {
                    _parseInfo.LocalVariableAccessed(referencer);
                }

                return(new CallVariableAction(referencer, index));
            }

            // Check value in array.
            if (index != null && index.Length > 0)
            {
                if (!variable.CanBeIndexed)
                {
                    Error("This variable type cannot be indexed.", variableRange);
                }
                else
                {
                    return(new ValueInArrayAction(_parseInfo, (IExpression)variable, index));
                }
            }

            // Function group.
            if (variable is MethodGroup methodGroup)
            {
                return(new CallMethodGroup(_parseInfo, variableRange, methodGroup));
            }

            return((IExpression)variable);
        }
コード例 #2
0
 void DefaultEventPlayerRestrictedCall() => _parseInfo.RestrictedCallHandler.AddRestrictedCall(
     new RestrictedCall(RestrictedCallType.EventPlayer, _parseInfo.GetLocation(CallRange), RestrictedCall.Message_EventPlayerDefault(_name))
     );