예제 #1
0
        public override IAstNode VisitWriteStmt(MicroCParser.WriteStmtContext context)
        {
            var    label     = ++_label;
            IAExpr value     = Visit(context.a_expr()) as IAExpr;
            var    writeStmt = new WriteStmt(value);

            writeStmt.Label = label;
            return(writeStmt);
        }
예제 #2
0
        protected override ILattice <FVDomain> TransferFunctions(int label)
        {
            var block     = GetBlock(label);
            var domain    = _analysisCircle[label].GetDomain();
            var newDomain = block switch
            {
                AssignStmt assignStmt => AssignTransfer(assignStmt, domain),
                RecAssignStmt recAssignStmt => RecAssignTransfer(recAssignStmt, domain),
                IfStmt ifStmt => ConditionTransfer(ifStmt.Condition, domain),
                IfElseStmt ifElseStmt => ConditionTransfer(ifElseStmt.Condition, domain),
                WhileStmt whileStmt => ConditionTransfer(whileStmt.Condition, domain),
                WriteStmt writeStmt => WriteTransfer(writeStmt, domain),
                ReadStmt readStmt => ReadTransfer(readStmt, domain),
                _ => new FVDomain(),
            };

            return(new FVLattice(newDomain));
        }
예제 #3
0
        protected override ILattice <IADomain> TransferFunctions(int label)
        {
            var block     = GetBlock(label);
            var domain    = _analysisCircle[label].GetDomain();
            var newDomain = block switch
            {
                IntDecl intDecl => IntDeclTransfer(intDecl, domain),
                ArrayDecl arrayDecl => ArrayDeclTransfer(arrayDecl, domain),
                RecordDecl recordDecl => RecDeclTransfer(recordDecl, domain),
                AssignStmt assignStmt => AssignTransfer(assignStmt, domain),
                RecAssignStmt recAssignStmt => RecAssignTransfer(recAssignStmt, domain),
                IfStmt ifStmt => IdTransfer(ifStmt, domain),
                IfElseStmt ifElseStmt => IdTransfer(ifElseStmt, domain),
                WhileStmt whileStmt => IdTransfer(whileStmt, domain),
                WriteStmt writeStmt => IdTransfer(writeStmt, domain),
                ReadStmt readStmt => ReadTransfer(readStmt, domain),
                _ => Bottom().GetDomain(),
            };

            return(new IALattice(newDomain));
        }
예제 #4
0
 private FVDomain WriteTransfer(WriteStmt writeStmt, FVDomain domain) =>
 domain.Union(AnalysisUtil.FreeVariables(writeStmt.Left)).ToFVDomain();
예제 #5
0
 private DSDomain WriteTransfer(WriteStmt writeStmt, DSDomain domain) => CopyDomain(domain);