public override object VisitForeignFunDecl(PParser.ForeignFunDeclContext context)
        {
            // FUN name=Iden
            var fun = (Function)nodesToDeclarations.Get(context);

            // LPAREN funParamList? RPAREN
            var paramList = context.funParamList() != null
                                ? (Variable[])Visit(context.funParamList())
                                : new Variable[0];

            fun.Signature.Parameters.AddRange(paramList);

            // (COLON type)?
            fun.Signature.ReturnType = ResolveType(context.type());

            // annotationSet?
            if (context.annotationSet() != null)
            {
                throw new NotImplementedException("function annotations");
            }

            // SEMI
            // no function body
            fun.Role |= FunctionRole.Foreign;
            return(fun);
        }
Exemple #2
0
        public override object VisitForeignFunDecl(PParser.ForeignFunDeclContext context)
        {
            // FUN name=Iden
            var fun = (Function)nodesToDeclarations.Get(context);

            // LPAREN funParamList? RPAREN
            var paramList = context.funParamList() != null
                ? (Variable[])Visit(context.funParamList())
                : new Variable[0];

            fun.Signature.Parameters.AddRange(paramList);

            // (COLON type)?
            fun.Signature.ReturnType = ResolveType(context.type());

            // SEMI
            // no function body
            fun.Role |= FunctionRole.Foreign;

            // Creates
            foreach (var createdInterface in context._interfaces)
            {
                if (CurrentScope.Lookup(createdInterface.GetText(), out Interface @interface))
                {
                    fun.AddCreatesInterface(@interface);
                }
                else
                {
                    throw Handler.MissingDeclaration(createdInterface, "interface", createdInterface.GetText());
                }
            }
            return(fun);
        }