コード例 #1
0
ファイル: SymbolTable.cs プロジェクト: b-xiang/Armada
        public void AddEnablingConstraint(Program prog, ArmadaPC pc, Expression e)
        {
            if (!constraints.ContainsKey(pc))
            {
                constraints[pc] = new EnablingConstraintCollector(prog);
            }
            var constraintCollector = constraints[pc];
            var context             = new EnablingConstraintResolutionContext(constraintCollector, method.Name, symbols);
            var rvalue = context.ResolveAsRValue(e);

            constraintCollector.AddConjunct(rvalue.UndefinedBehaviorAvoidance);
            constraintCollector.AddConjunct(rvalue.Val);
        }
コード例 #2
0
ファイル: SymbolTable.cs プロジェクト: ScriptBox21/MS-Armada
        public void ParseMethodBody(ArmadaSymbolTable symbols)
        {
            var context = new ParseContext(prog, symbols, this);

            parsedBody = ArmadaStatement.ParseStatement(context, method.Body);
            var startPC = GenerateOnePC();
            var endPC   = parsedBody.AssignPCs(prog, symbols, this, startPC);

            ArmadaStatement.CollectReturnPCs(parsedBody, returnPCs);
            ArmadaStatement.ComputeNonyieldingPCs(parsedBody, nonyieldingPCs);

            foreach (var statement in parsedBody)
            {
                if (statement is ArmadaAssumeStatement)
                {
                    var s        = (ArmadaAssumeStatement)statement;
                    var assumePC = s.StartPC;
                    if (!constraints.ContainsKey(assumePC))
                    {
                        constraints[assumePC] = new EnablingConstraintCollector(prog);
                    }
                    s.AddEnablingConstraint(symbols, this, constraints[assumePC]);
                }
            }

            symbols.AssociateLabelWithPC("Start", startPC);
            symbols.AssociateLabelWithPC("End", endPC);
            foreach (var statement in parsedBody)
            {
                var stmt = statement.Stmt;
                if (stmt != null)
                {
                    for (var lbl = stmt.Labels; lbl != null; lbl = lbl.Next)
                    {
                        if (lbl.Data != null && lbl.Data.Name != null)
                        {
                            symbols.AssociateLabelWithPC(lbl.Data.Name, statement.StartPC);
                        }
                    }
                }
            }
        }