Example #1
0
        public override IPStmt VisitCtorStmt(PParser.CtorStmtContext context)
        {
            string machineName = context.iden().GetText();

            if (!table.Lookup(machineName, out Machine targetMachine))
            {
                throw handler.MissingDeclaration(context.iden(), "machine", machineName);
            }
            var args = (from arg in context.rvalueList()?.rvalue() ?? Enumerable.Empty <PParser.RvalueContext>() select exprVisitor.Visit(arg)).ToList();

            TypeCheckingUtils.ValidatePayloadTypes(handler, context, targetMachine.PayloadType, args);
            return(new CtorStmt(context, targetMachine, args));
        }
Example #2
0
        public override IPStmt VisitCtorStmt(PParser.CtorStmtContext context)
        {
            string interfaceName = context.iden().GetText();

            if (!table.Lookup(interfaceName, out Interface targetInterface))
            {
                throw handler.MissingDeclaration(context.iden(), "interface", interfaceName);
            }

            List <IPExpr> args = TypeCheckingUtils.VisitRvalueList(context.rvalueList(), exprVisitor).ToList();

            TypeCheckingUtils.ValidatePayloadTypes(handler, context, targetInterface.PayloadType, args);
            return(new CtorStmt(context, targetInterface, args));
        }