Exemplo n.º 1
0
        protected override void Initialize()
        {
            worklist       = new Stack <InstructionNode>();
            transformRules = new List <TransformRule>();

            var symbolDictionary = new SymbolDictionary();

            symbolDictionary.Add(Architecture);
            symbolDictionary.Add(IRInstructionList.List);

            foreach (var rule in Rules.List)
            {
                var matchTokens     = Tokenizer.Parse(rule.Match, ParseType.Instructions);
                var criteriaTokens  = Tokenizer.Parse(rule.Criteria, ParseType.Expression);
                var transformTokens = Tokenizer.Parse(rule.Transform, ParseType.Instructions);

                var matchNodes         = NodeParser.Parse(matchTokens, symbolDictionary);
                var criteriaExpression = ExpressionParser.Parse(criteriaTokens);
                var transformNodes     = NodeParser.Parse(transformTokens, symbolDictionary);

                var transformRule = new TransformRule(matchNodes, criteriaExpression, transformNodes);

                transformRules.Add(transformRule);
            }
        }
Exemplo n.º 2
0
        private static void Test1()
        {
            var map = new SymbolDictionary();

            map.Add(IRInstructionList.List);

            var match = new List <string> {
                "(IR.MulUnsigned 1 x)",
                "(MulUnsigned 1 x)",
                "(IR.AddUnsigned32(IR.MulUnsigned x y)(IR.MulUnsigned x z))",
                "(AddUnsigned32(MulUnsigned x y)(MulUnsigned x z))",
                "(MulUnsigned x (AddUnsigned32 y z))",
                "(MulUnsigned 1 x)",
                "x",
                "(MulUnsigned (Const c1) (Const c2))",
                "[c1 * c2]",
                "(MulUnsigned 1 2) ",
                "[1 * 2]"
            };

            var tokenized = new List <List <Token> >();

            foreach (var m in match)
            {
                tokenized.Add(Tokenizer.Parse(m, m.StartsWith("(") ? ParseType.Instructions : ParseType.Expression));
            }

            return;
        }
 public override object Build(CodeContext context, object[] args) {
     SymbolDictionary res = new SymbolDictionary();
     for (int i = _argIndex; i < _argIndex + _names.Length; i++) {
         res.Add(_names[i - _argIndex], args[i]);
     }
     return res;
 }
Exemplo n.º 4
0
        public override object Build(CodeContext context, object[] args)
        {
            SymbolDictionary res = new SymbolDictionary();

            for (int i = _argIndex; i < _argIndex + _names.Length; i++)
            {
                res.Add(_names[i - _argIndex], args[i]);
            }
            return(res);
        }
Exemplo n.º 5
0
 public virtual void SetItem(SymbolId name, object value)
 {        //ECMA 8.6.2.2 Put
     if (!CanSetItem(name))
     {
         return;
     }
     if (members.ContainsKey(name))
     {
         members[name] = value;
     }
     else
     {
         members.Add(name, value);
     }
 }