Esempio n. 1
0
        // handles emiting the correct instructions for the function
        public override int VisitFunction_call(YarnSpinnerParser.Function_callContext context)
        {
            string functionName = context.FUNC_ID().GetText();

            this.GenerateCodeForFunctionCall(functionName, context, context.expression());

            return(0);
        }
Esempio n. 2
0
        // emits the required bytecode for the function call
        private void GenerateCodeForFunctionCall(string functionName, YarnSpinnerParser.Function_callContext functionContext, YarnSpinnerParser.ExpressionContext[] parameters)
        {
            // generate the instructions for all of the parameters
            foreach (var parameter in parameters)
            {
                this.Visit(parameter);
            }

            // push the number of parameters onto the stack
            this.compiler.Emit(OpCode.PushFloat, functionContext.Start, new Operand(parameters.Length));

            // then call the function itself
            this.compiler.Emit(OpCode.CallFunc, functionContext.Start, new Operand(functionName));
        }
Esempio n. 3
0
        public override string VisitFunction_call([NotNull] YarnSpinnerParser.Function_callContext context)
        {
            var functionName = context.FUNC_ID().GetText();

            if (functionName.Equals("visited") || functionName.Equals("visited_count"))
            {
                // we aren't bothering to test anything about the value itself
                // if it isn't a static string we'll get back null so can ignore it
                // if the func has more than one parameter later on it will cause an error so again can ignore
                var result = Visit(context.expression()[0]);

                if (result != null)
                {
                    TrackingNode.Add(result);
                }
            }

            return(null);
        }
Esempio n. 4
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="YarnSpinnerParser.function_call"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitFunction_call([NotNull] YarnSpinnerParser.Function_callContext context)
 {
 }
Esempio n. 5
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="YarnSpinnerParser.function_call"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitFunction_call([NotNull] YarnSpinnerParser.Function_callContext context)
 {
     return(VisitChildren(context));
 }