示例#1
0
        public void Parse()
        {
            output = new List <IToken>();
            List <string> items       = new List <string>(this.input.Split(" "));
            int           singleValue = 0;

            try {
                if (items.Count == 1)
                {
                    singleValue = int.Parse(items[0]);
                    IToken token = new Constant(singleValue);
                    token.Accept(visitor);
                    return;
                }
            } catch (Exception) {
            }
            TokenFactory        tokenFacto = new TokenFactory();
            TreeModifierFactory treeFacto  = new TreeModifierFactory();
            ASTBuilder          factory    = new ASTBuilder(tokenFacto, treeFacto);

            foreach (String item in items)
            {
                factory.Create(item);
            }
            this.output = factory.AST;
            if (this.output.Count == 1 && this.output[0].GetType() == typeof(Operand))
            {
                visitor = new SingleValueVisitor();
            }
            foreach (IToken token in this.output)
            {
                token.Accept(visitor);
            }
        }
示例#2
0
        public void EqbSegmentConstants()
        {
            Constant seg1 = Constant.Create(PrimitiveType.SegmentSelector, 0x1234);
            Constant seg2 = Constant.Create(PrimitiveType.SegmentSelector, 0x1234);

            seg1.Accept(eqb);
            seg2.Accept(eqb);
            Assert.IsNotNull(seg1.TypeVariable);
            Assert.AreSame(seg1.TypeVariable, seg2.TypeVariable);
        }
 public void EqSegmentConstantsWithAllocatedSegment()
 {
     var tmp = new TemporaryStorage("seg1234", 0, PrimitiveType.SegmentSelector);
     var segment = new ImageSegment(
             "seg1234",
             new ByteMemoryArea(Address.SegPtr(0x1234, 0), new byte[100]),
             AccessMode.ReadWriteExecute)
     {
         Identifier = new Identifier(tmp.Name, PrimitiveType.SegmentSelector, tmp)
     };
     eqb.EnsureSegmentTypeVariables(new[] { segment });
     Constant seg1 = Constant.Create(PrimitiveType.SegmentSelector, 0x1234);
     seg1.Accept(eqb);
     Assert.AreSame(seg1.TypeVariable.Class, segment.Identifier.TypeVariable.Class);
 }