Esempio n. 1
0
        public override object Visit(IdentifierProcedureCallAstNode procNode)
        {
            object value = SymbolTable.Get(procNode.Name);
            var    type  = value.GetType();

            var paramList  = procNode.Params.Select(p => p.Accept(this)).ToArray();
            var paramTypes = paramList.Select(p => p.GetType()).ToArray();

            var anyMethod = type.GetMethod("Invoke");

            if (anyMethod == null)
            {
                throw Error(procNode, $"'{procNode.Name}' is not an Invokable procedure.");
            }

            var method = type.GetMethod("Invoke", paramTypes);

            if (method == null)
            {
                throw Error(procNode, $"'{procNode.Name}' called with invalid arguments.");
            }

            return(method.Invoke(value, paramList));
        }
Esempio n. 2
0
 public virtual object Visit(IdentifierProcedureCallAstNode node)
 {
     return(null);
 }