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;
 }
Esempio n. 2
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);
            }
        }
        private IList <string> ParseLabelSymbols(string[] assemblyInstructions)
        {
            var remainingAssemblyInstructions = new List <string>();

            for (int i = 0; i < assemblyInstructions.Length; i++)
            {
                var assemblyInstruction = GetNoncomment(assemblyInstructions[i]);

                if (string.IsNullOrWhiteSpace(assemblyInstruction))
                {
                    continue;
                }

                if (IsLabelSymbol(assemblyInstruction, out string labelSymbol))
                {
                    if (!SymbolDictionary.ContainsKey(labelSymbol))
                    {
                        SymbolDictionary[labelSymbol] = remainingAssemblyInstructions.Count; // The address should be the address of the proceeding instruction.
                    }

                    continue;
                }

                remainingAssemblyInstructions.Add(assemblyInstruction);
            }

            return(remainingAssemblyInstructions);
        }
Esempio n. 4
0
        public bool GetAxisSymbols(string symbolname, out string x_axis, out string y_axis, out string x_axis_description, out string y_axis_description, out string z_axis_description)
        {
            bool retval = false;

            x_axis             = SymbolDictionary.GetSymbolXAxis(symbolname);
            y_axis             = SymbolDictionary.GetSymbolYAxis(symbolname);
            x_axis_description = "";
            y_axis_description = "";

            if (x_axis != "")
            {
                x_axis_description = SymbolDictionary.GetSymbolUnitOfMeasure(x_axis);
            }
            if (x_axis != "")
            {
                y_axis_description = SymbolDictionary.GetSymbolUnitOfMeasure(y_axis);
            }
            z_axis_description = SymbolDictionary.GetSymbolUnitOfMeasure(symbolname);

            if (y_axis != "")
            {
                retval = true;
            }
            return(retval);
        }
Esempio n. 5
0
        protected override void Initialize()
        {
            const PropertyFlag propertyFlags = PropertyFlag.Configurable | PropertyFlag.Writable;
            var properties = new PropertyDictionary(12, checkExistingKeys: false)
            {
                ["length"]      = new PropertyDescriptor(0, PropertyFlag.Configurable),
                ["constructor"] = new PropertyDescriptor(_mapConstructor, PropertyFlag.NonEnumerable),
                ["clear"]       = new PropertyDescriptor(new ClrFunctionInstance(Engine, "clear", Clear, 0, PropertyFlag.Configurable), propertyFlags),
                ["delete"]      = new PropertyDescriptor(new ClrFunctionInstance(Engine, "delete", Delete, 1, PropertyFlag.Configurable), propertyFlags),
                ["entries"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "entries", Entries, 0, PropertyFlag.Configurable), propertyFlags),
                ["forEach"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "forEach", ForEach, 1, PropertyFlag.Configurable), propertyFlags),
                ["get"]         = new PropertyDescriptor(new ClrFunctionInstance(Engine, "get", Get, 1, PropertyFlag.Configurable), propertyFlags),
                ["has"]         = new PropertyDescriptor(new ClrFunctionInstance(Engine, "has", Has, 1, PropertyFlag.Configurable), propertyFlags),
                ["keys"]        = new PropertyDescriptor(new ClrFunctionInstance(Engine, "keys", Keys, 0, PropertyFlag.Configurable), propertyFlags),
                ["set"]         = new PropertyDescriptor(new ClrFunctionInstance(Engine, "set", Set, 2, PropertyFlag.Configurable), propertyFlags),
                ["values"]      = new PropertyDescriptor(new ClrFunctionInstance(Engine, "values", Values, 0, PropertyFlag.Configurable), propertyFlags),
                ["size"]        = new GetSetPropertyDescriptor(get: new ClrFunctionInstance(Engine, "get size", Size, 0, PropertyFlag.Configurable), set: null, PropertyFlag.Configurable)
            };

            SetProperties(properties);

            var symbols = new SymbolDictionary(2)
            {
                [GlobalSymbolRegistry.Iterator]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "iterator", Entries, 1, PropertyFlag.Configurable), propertyFlags),
                [GlobalSymbolRegistry.ToStringTag] = new PropertyDescriptor("Map", false, false, true),
            };

            SetSymbols(symbols);
        }
        public OrderOfBattleViewModel()
        {
            Mediator.Register(Constants.ACTION_CANCEL, DoActionCancel);
            Mediator.Register(Constants.ACTION_ITEM_WITH_GUID_REMOVED, DoActionItemWithGuidRemoved);
            Mediator.Register(Constants.ACTION_ITEM_WITH_GUID_ADDED, DoActionItemWithGuidAdded);

            // Check the ArcGIS Runtime is initialized
            if (!ArcGISRuntimeEnvironment.IsInitialized)
            {
                ArcGISRuntimeEnvironment.Initialize();
            }

            // hook the commands
            SearchCommand        = new RelayCommand(OnSearch);
            SymbolChangedCommand = new RelayCommand(OnSymbolChanged);

            // Create a new MilitarySymbolDictionary instance
            MilitarySymbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection <SymbolViewModel>();

            // Set the image size
            _imageSize = 96;

            // org tree view
            _groupSymbol = new SymbolGroupViewModel(SymbolLoader.LoadSymbolWrapper());

            ExpandGroupSymbol(_groupSymbol);
        }
        public OrderOfBattleViewModel()
        {
            Mediator.Register(Constants.ACTION_CANCEL, DoActionCancel);
            Mediator.Register(Constants.ACTION_ITEM_WITH_GUID_REMOVED, DoActionItemWithGuidRemoved);
            Mediator.Register(Constants.ACTION_ITEM_WITH_GUID_ADDED, DoActionItemWithGuidAdded);

            // Check the ArcGIS Runtime is initialized
            if (!ArcGISRuntimeEnvironment.IsInitialized)
            {
                ArcGISRuntimeEnvironment.Initialize();
            }

            // hook the commands
            SearchCommand = new RelayCommand(OnSearch);
            SymbolChangedCommand = new RelayCommand(OnSymbolChanged);

            // Create a new MilitarySymbolDictionary instance
            MilitarySymbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection<SymbolViewModel>();

            // Set the image size
            _imageSize = 96;

            // org tree view
            _groupSymbol = new SymbolGroupViewModel(SymbolLoader.LoadSymbolWrapper());

            ExpandGroupSymbol(_groupSymbol);
        }
Esempio n. 8
0
        protected override void Initialize()
        {
            var properties = new PropertyDictionary(14, checkExistingKeys: false)
            {
                ["apply"]                    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "apply", Apply, 3, PropertyFlag.Configurable), true, false, true),
                ["construct"]                = new PropertyDescriptor(new ClrFunctionInstance(Engine, "construct", Construct, 2, PropertyFlag.Configurable), true, false, true),
                ["defineProperty"]           = new PropertyDescriptor(new ClrFunctionInstance(Engine, "defineProperty", DefineProperty, 3, PropertyFlag.Configurable), true, false, true),
                ["deleteProperty"]           = new PropertyDescriptor(new ClrFunctionInstance(Engine, "deleteProperty", DeleteProperty, 2, PropertyFlag.Configurable), true, false, true),
                ["get"]                      = new PropertyDescriptor(new ClrFunctionInstance(Engine, "get", Get, 2, PropertyFlag.Configurable), true, false, true),
                ["getOwnPropertyDescriptor"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "getOwnPropertyDescriptor", GetOwnPropertyDescriptor, 2, PropertyFlag.Configurable), true, false, true),
                ["getPrototypeOf"]           = new PropertyDescriptor(new ClrFunctionInstance(Engine, "getPrototypeOf", GetPrototypeOf, 1, PropertyFlag.Configurable), true, false, true),
                ["has"]                      = new PropertyDescriptor(new ClrFunctionInstance(Engine, "has", Has, 2, PropertyFlag.Configurable), true, false, true),
                ["isExtensible"]             = new PropertyDescriptor(new ClrFunctionInstance(Engine, "isExtensible", IsExtensible, 1, PropertyFlag.Configurable), true, false, true),
                ["ownKeys"]                  = new PropertyDescriptor(new ClrFunctionInstance(Engine, "ownKeys", OwnKeys, 1, PropertyFlag.Configurable), true, false, true),
                ["preventExtensions"]        = new PropertyDescriptor(new ClrFunctionInstance(Engine, "preventExtensions", PreventExtensions, 1, PropertyFlag.Configurable), true, false, true),
                ["set"]                      = new PropertyDescriptor(new ClrFunctionInstance(Engine, "set", Set, 3, PropertyFlag.Configurable), true, false, true),
                ["setPrototypeOf"]           = new PropertyDescriptor(new ClrFunctionInstance(Engine, "setPrototypeOf", SetPrototypeOf, 2, PropertyFlag.Configurable), true, false, true),
            };

            SetProperties(properties);

            var symbols = new SymbolDictionary(1)
            {
                [GlobalSymbolRegistry.ToStringTag] = new PropertyDescriptor("Reflect", false, false, true)
            };

            SetSymbols(symbols);
        }
        public MainWindow()
        {
            // License setting and ArcGIS Runtime initialization is done in Application.xaml.cs.

            InitializeComponent();
            _symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525C);

            IEnumerable<SymbolProperties> symbolProperties = _symbolDictionary.FindSymbols(null, null);
            var allSymbols = symbolProperties.ToList();
            foreach (var s in allSymbols)
            {
                string name = s.Name;
                if (string.IsNullOrEmpty(name) || !(s.Values.ContainsKey("SymbolID")))
                    continue;

                string symbolId = s.Values["SymbolID"].Replace('*','-');
                string geoType = s.Values["GeometryType"];

                // Need this table to be able to get the geometry type & other properties later
                sidc2SymbolProps[symbolId] = s;

                // To see symbols list:
                // System.Diagnostics.Trace.WriteLine(name + ":" + symbolId + ":" + geoType);
            }

            ListBox_Swatches.ItemsSource = swatches;
        }
Esempio n. 10
0
        public MainWindow()
        {
            // License setting and ArcGIS Runtime initialization is done in Application.xaml.cs.

            InitializeComponent();
            _symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525C);

            IEnumerable <SymbolProperties> symbolProperties = _symbolDictionary.FindSymbols(null, null);
            var allSymbols = symbolProperties.ToList();

            foreach (var s in allSymbols)
            {
                string name = s.Name;
                if (string.IsNullOrEmpty(name) || !(s.Values.ContainsKey("SymbolID")))
                {
                    continue;
                }

                string symbolId = s.Values["SymbolID"].Replace('*', '-');
                string geoType  = s.Values["GeometryType"];

                // Need this table to be able to get the geometry type & other properties later
                sidc2SymbolProps[symbolId] = s;

                // To see symbols list:
                // System.Diagnostics.Trace.WriteLine(name + ":" + symbolId + ":" + geoType);
            }

            ListBox_Swatches.ItemsSource = swatches;
        }
Esempio n. 11
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;
        }
Esempio n. 12
0
        public FrontendPipeline(string grammar)
        {
            Rules <IASTNode> rules;

            (Lexer, PrototypeDictionary, rules) = new ParsersParser1().ParseParser(grammar);
            SymbolDictionary = Lexer.SymbolDictionary();
            Parser           = new Ll1Parser <IASTNode>(rules, SymbolDictionary, (token, id) => new ASTLeaf(token, id));
        }
Esempio n. 13
0
        public (RegexLexer, PrototypeDictionary, Rules <IASTNode>) ParseParser(string code)
        {
            pd       = new PrototypeDictionary();
            resultSd = new SymbolDictionary();
            var tokens = pl.ParseAll(code).ToList();

            return(((RegexLexer, PrototypeDictionary, Rules <IASTNode>))pParser.Parse(tokens));
        }
Esempio n. 14
0
        protected override void Initialize()
        {
            var properties = new PropertyDictionary(45, checkExistingKeys: false)
            {
                ["abs"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "abs", Abs, 1, PropertyFlag.Configurable), true, false, true),
                ["acos"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "acos", Acos, 1, PropertyFlag.Configurable), true, false, true),
                ["acosh"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "acosh", Acosh, 1, PropertyFlag.Configurable), true, false, true),
                ["asin"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "asin", Asin, 1, PropertyFlag.Configurable), true, false, true),
                ["asinh"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "asinh", Asinh, 1, PropertyFlag.Configurable), true, false, true),
                ["atan"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "atan", Atan, 1, PropertyFlag.Configurable), true, false, true),
                ["atanh"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "atanh", Atanh, 1, PropertyFlag.Configurable), true, false, true),
                ["atan2"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "atan2", Atan2, 2, PropertyFlag.Configurable), true, false, true),
                ["ceil"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "ceil", Ceil, 1, PropertyFlag.Configurable), true, false, true),
                ["cos"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "cos", Cos, 1, PropertyFlag.Configurable), true, false, true),
                ["cosh"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "cosh", Cosh, 1, PropertyFlag.Configurable), true, false, true),
                ["exp"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "exp", Exp, 1, PropertyFlag.Configurable), true, false, true),
                ["expm1"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "expm1", Expm1, 1, PropertyFlag.Configurable), true, false, true),
                ["floor"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "floor", Floor, 1, PropertyFlag.Configurable), true, false, true),
                ["log"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "log", Log, 1, PropertyFlag.Configurable), true, false, true),
                ["log1p"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "log1p", Log1p, 1, PropertyFlag.Configurable), true, false, true),
                ["log2"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "log2", Log2, 1, PropertyFlag.Configurable), true, false, true),
                ["log10"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "log10", Log10, 1, PropertyFlag.Configurable), true, false, true),
                ["max"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "max", Max, 2, PropertyFlag.Configurable), true, false, true),
                ["min"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "min", Min, 2, PropertyFlag.Configurable), true, false, true),
                ["pow"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "pow", Pow, 2, PropertyFlag.Configurable), true, false, true),
                ["random"]  = new PropertyDescriptor(new ClrFunctionInstance(Engine, "random", Random, 0, PropertyFlag.Configurable), true, false, true),
                ["round"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "round", Round, 1, PropertyFlag.Configurable), true, false, true),
                ["fround"]  = new PropertyDescriptor(new ClrFunctionInstance(Engine, "fround", Fround, 1, PropertyFlag.Configurable), true, false, true),
                ["sin"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "sin", Sin, 1, PropertyFlag.Configurable), true, false, true),
                ["sinh"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "sinh", Sinh, 1, PropertyFlag.Configurable), true, false, true),
                ["sqrt"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "sqrt", Sqrt, 1, PropertyFlag.Configurable), true, false, true),
                ["tan"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "tan", Tan, 1, PropertyFlag.Configurable), true, false, true),
                ["tanh"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "tanh", Tanh, 1, PropertyFlag.Configurable), true, false, true),
                ["trunc"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "trunc", Truncate, 1, PropertyFlag.Configurable), true, false, true),
                ["sign"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "sign", Sign, 1, PropertyFlag.Configurable), true, false, true),
                ["cbrt"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "cbrt", Cbrt, 1, PropertyFlag.Configurable), true, false, true),
                ["hypot"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "hypot", Hypot, 2, PropertyFlag.Configurable), true, false, true),
                ["imul"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "imul", Imul, 2, PropertyFlag.Configurable), true, false, true),
                ["clz32"]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "clz32", Clz32, 1, PropertyFlag.Configurable), true, false, true),
                ["E"]       = new PropertyDescriptor(System.Math.E, false, false, false),
                ["LN10"]    = new PropertyDescriptor(System.Math.Log(10), false, false, false),
                ["LN2"]     = new PropertyDescriptor(System.Math.Log(2), false, false, false),
                ["LOG2E"]   = new PropertyDescriptor(System.Math.Log(System.Math.E, 2), false, false, false),
                ["LOG10E"]  = new PropertyDescriptor(System.Math.Log(System.Math.E, 10), false, false, false),
                ["PI"]      = new PropertyDescriptor(System.Math.PI, false, false, false),
                ["SQRT1_2"] = new PropertyDescriptor(System.Math.Sqrt(0.5), false, false, false),
                ["SQRT2"]   = new PropertyDescriptor(System.Math.Sqrt(2), false, false, false)
            };

            SetProperties(properties);

            var symbols = new SymbolDictionary(1)
            {
                [GlobalSymbolRegistry.ToStringTag] = new PropertyDescriptor(new JsString("Math"), PropertyFlag.Configurable)
            };

            SetSymbols(symbols);
        }
Esempio n. 15
0
 public void Print(SymbolDictionary sd, string offset = "")
 {
     Console.WriteLine($"{offset}{Prototype.Name()}:");
     foreach (var field in Prototype.Names())
     {
         Console.WriteLine($"{offset}   {field}:");
         Values[Prototype.IdxOf(field)].Print(sd, $"{offset}      ");
     }
 }
Esempio n. 16
0
 public Ll1Parser(Rules <T> rules, SymbolDictionary symbolDictionary, Func <Token, int, T> factory)
 {
     _symbolDictionary = symbolDictionary;
     this._factory     = factory;
     _rules            = rules;
     _first            = CalculateFirst();
     _consumers        = _symbolDictionary.GetAll(SymbolType.NonTerminal)
                         .ToDictionary(x => x, MakeConsumer);
 }
Esempio n. 17
0
 public void Print(SymbolDictionary sd, string offset = "")
 {
     Console.WriteLine($"{offset}{Prototype.Name()}:");
     for (var i = 0; i < _values.Count; i++)
     {
         Console.WriteLine($"{offset}   {i}:");
         _values[i].Print(sd, $"{offset}      ");
     }
 }
        public void GetSet_RoundTrip_WithUntypedSymbol()
        {
            var symbol = new Symbol();
            var dictionary = new SymbolDictionary();

            dictionary.Set(symbol, 42);

            Assert.AreEqual(42, dictionary.Get<int>(symbol));
        }
        protected override void Initialize()
        {
            var symbols = new SymbolDictionary(1)
            {
                [GlobalSymbolRegistry.Species] = new GetSetPropertyDescriptor(get: new ClrFunctionInstance(_engine, "get [Symbol.species]", (thisObj, _) => thisObj, 0, PropertyFlag.Configurable), set: Undefined, PropertyFlag.Configurable)
            };

            SetSymbols(symbols);
        }
Esempio n. 20
0
        protected override void Initialize()
        {
            const PropertyFlag lengthFlags   = PropertyFlag.Configurable;
            const PropertyFlag propertyFlags = lengthFlags | PropertyFlag.Writable;

            var trimStart  = new PropertyDescriptor(new ClrFunctionInstance(Engine, "trimStart", TrimStart, 0, lengthFlags), propertyFlags);
            var trimEnd    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "trimEnd", TrimEnd, 0, lengthFlags), propertyFlags);
            var properties = new PropertyDictionary(35, checkExistingKeys: false)
            {
                ["constructor"]       = new PropertyDescriptor(_constructor, PropertyFlag.NonEnumerable),
                ["toString"]          = new PropertyDescriptor(new ClrFunctionInstance(Engine, "toString", ToStringString, 0, lengthFlags), propertyFlags),
                ["valueOf"]           = new PropertyDescriptor(new ClrFunctionInstance(Engine, "valueOf", ValueOf, 0, lengthFlags), propertyFlags),
                ["charAt"]            = new PropertyDescriptor(new ClrFunctionInstance(Engine, "charAt", CharAt, 1, lengthFlags), propertyFlags),
                ["charCodeAt"]        = new PropertyDescriptor(new ClrFunctionInstance(Engine, "charCodeAt", CharCodeAt, 1, lengthFlags), propertyFlags),
                ["codePointAt"]       = new PropertyDescriptor(new ClrFunctionInstance(Engine, "codePointAt", CodePointAt, 1, lengthFlags), propertyFlags),
                ["concat"]            = new PropertyDescriptor(new ClrFunctionInstance(Engine, "concat", Concat, 1, lengthFlags), propertyFlags),
                ["indexOf"]           = new PropertyDescriptor(new ClrFunctionInstance(Engine, "indexOf", IndexOf, 1, lengthFlags), propertyFlags),
                ["endsWith"]          = new PropertyDescriptor(new ClrFunctionInstance(Engine, "endsWith", EndsWith, 1, lengthFlags), propertyFlags),
                ["startsWith"]        = new PropertyDescriptor(new ClrFunctionInstance(Engine, "startsWith", StartsWith, 1, lengthFlags), propertyFlags),
                ["lastIndexOf"]       = new PropertyDescriptor(new ClrFunctionInstance(Engine, "lastIndexOf", LastIndexOf, 1, lengthFlags), propertyFlags),
                ["localeCompare"]     = new PropertyDescriptor(new ClrFunctionInstance(Engine, "localeCompare", LocaleCompare, 1, lengthFlags), propertyFlags),
                ["match"]             = new PropertyDescriptor(new ClrFunctionInstance(Engine, "match", Match, 1, lengthFlags), propertyFlags),
                ["matchAll"]          = new PropertyDescriptor(new ClrFunctionInstance(Engine, "matchAll", MatchAll, 1, lengthFlags), propertyFlags),
                ["replace"]           = new PropertyDescriptor(new ClrFunctionInstance(Engine, "replace", Replace, 2, lengthFlags), propertyFlags),
                ["replaceAll"]        = new PropertyDescriptor(new ClrFunctionInstance(Engine, "replaceAll", ReplaceAll, 2, lengthFlags), propertyFlags),
                ["search"]            = new PropertyDescriptor(new ClrFunctionInstance(Engine, "search", Search, 1, lengthFlags), propertyFlags),
                ["slice"]             = new PropertyDescriptor(new ClrFunctionInstance(Engine, "slice", Slice, 2, lengthFlags), propertyFlags),
                ["split"]             = new PropertyDescriptor(new ClrFunctionInstance(Engine, "split", Split, 2, lengthFlags), propertyFlags),
                ["substr"]            = new PropertyDescriptor(new ClrFunctionInstance(Engine, "substr", Substr, 2), propertyFlags),
                ["substring"]         = new PropertyDescriptor(new ClrFunctionInstance(Engine, "substring", Substring, 2, lengthFlags), propertyFlags),
                ["toLowerCase"]       = new PropertyDescriptor(new ClrFunctionInstance(Engine, "toLowerCase", ToLowerCase, 0, lengthFlags), propertyFlags),
                ["toLocaleLowerCase"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "toLocaleLowerCase", ToLocaleLowerCase, 0, lengthFlags), propertyFlags),
                ["toUpperCase"]       = new PropertyDescriptor(new ClrFunctionInstance(Engine, "toUpperCase", ToUpperCase, 0, lengthFlags), propertyFlags),
                ["toLocaleUpperCase"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "toLocaleUpperCase", ToLocaleUpperCase, 0, lengthFlags), propertyFlags),
                ["trim"]      = new PropertyDescriptor(new ClrFunctionInstance(Engine, "trim", Trim, 0, lengthFlags), propertyFlags),
                ["trimStart"] = trimStart,
                ["trimEnd"]   = trimEnd,
                ["trimLeft"]  = trimStart,
                ["trimRight"] = trimEnd,
                ["padStart"]  = new PropertyDescriptor(new ClrFunctionInstance(Engine, "padStart", PadStart, 1, lengthFlags), propertyFlags),
                ["padEnd"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "padEnd", PadEnd, 1, lengthFlags), propertyFlags),
                ["includes"]  = new PropertyDescriptor(new ClrFunctionInstance(Engine, "includes", Includes, 1, lengthFlags), propertyFlags),
                ["normalize"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "normalize", Normalize, 0, lengthFlags), propertyFlags),
                ["repeat"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "repeat", Repeat, 1, lengthFlags), propertyFlags),
                ["at"]        = new PropertyDescriptor(new ClrFunctionInstance(Engine, "at", At, 1, lengthFlags), propertyFlags),
            };

            SetProperties(properties);

            var symbols = new SymbolDictionary(1)
            {
                [GlobalSymbolRegistry.Iterator] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "[Symbol.iterator]", Iterator, 0, lengthFlags), propertyFlags)
            };

            SetSymbols(symbols);
        }
Esempio n. 21
0
        protected override void Initialize()
        {
            const PropertyFlag lengthFlags = PropertyFlag.Configurable;

            GetSetPropertyDescriptor CreateGetAccessorDescriptor(string name, Func <RegExpInstance, JsValue> valueExtractor, JsValue protoValue = null)
            {
                return(new GetSetPropertyDescriptor(
                           get: new ClrFunctionInstance(Engine, name, (thisObj, arguments) =>
                {
                    if (ReferenceEquals(thisObj, this))
                    {
                        return protoValue ?? Undefined;
                    }

                    var r = thisObj as RegExpInstance;
                    if (r is null)
                    {
                        ExceptionHelper.ThrowTypeError(_realm);
                    }

                    return valueExtractor(r);
                }, 0, lengthFlags),
                           set: Undefined,
                           flags: PropertyFlag.Configurable));
            }

            const PropertyFlag propertyFlags = PropertyFlag.Configurable | PropertyFlag.Writable;
            var properties = new PropertyDictionary(12, checkExistingKeys: false)
            {
                ["constructor"] = new PropertyDescriptor(_constructor, propertyFlags),
                ["toString"]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "toString", ToRegExpString, 0, lengthFlags), propertyFlags),
                ["exec"]        = new PropertyDescriptor(new ClrFunctionInstance(Engine, "exec", _defaultExec, 1, lengthFlags), propertyFlags),
                ["test"]        = new PropertyDescriptor(new ClrFunctionInstance(Engine, "test", Test, 1, lengthFlags), propertyFlags),
                ["dotAll"]      = CreateGetAccessorDescriptor("get dotAll", r => r.DotAll),
                ["flags"]       = new GetSetPropertyDescriptor(get: new ClrFunctionInstance(Engine, "get flags", Flags, 0, lengthFlags), set: Undefined, flags: PropertyFlag.Configurable),
                ["global"]      = CreateGetAccessorDescriptor("get global", r => r.Global),
                ["ignoreCase"]  = CreateGetAccessorDescriptor("get ignoreCase", r => r.IgnoreCase),
                ["multiline"]   = CreateGetAccessorDescriptor("get multiline", r => r.Multiline),
                ["source"]      = new GetSetPropertyDescriptor(get: new ClrFunctionInstance(Engine, "get source", Source, 0, lengthFlags), set: Undefined, flags: PropertyFlag.Configurable),
                ["sticky"]      = CreateGetAccessorDescriptor("get sticky", r => r.Sticky),
                ["unicode"]     = CreateGetAccessorDescriptor("get unicode", r => r.FullUnicode)
            };

            SetProperties(properties);

            var symbols = new SymbolDictionary(5)
            {
                [GlobalSymbolRegistry.Match]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "[Symbol.match]", Match, 1, lengthFlags), propertyFlags),
                [GlobalSymbolRegistry.MatchAll] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "[Symbol.matchAll]", MatchAll, 1, lengthFlags), propertyFlags),
                [GlobalSymbolRegistry.Replace]  = new PropertyDescriptor(new ClrFunctionInstance(Engine, "[Symbol.replace]", Replace, 2, lengthFlags), propertyFlags),
                [GlobalSymbolRegistry.Search]   = new PropertyDescriptor(new ClrFunctionInstance(Engine, "[Symbol.search]", Search, 1, lengthFlags), propertyFlags),
                [GlobalSymbolRegistry.Split]    = new PropertyDescriptor(new ClrFunctionInstance(Engine, "[Symbol.split]", Split, 2, lengthFlags), propertyFlags)
            };

            SetSymbols(symbols);
        }
Esempio n. 22
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);
        }
Esempio n. 23
0
 public void Print(SymbolDictionary sd)
 {
     foreach (var rule in RuleList)
     {
         Console.Write(sd[rule.NonTerminal].name);
         Console.Write(" -> ");
         Console.Write(string.Join(" ", rule.Sequence.Select(s => sd[s].name)));
         Console.WriteLine($" {{ {rule.Callback} }}");
     }
 }
Esempio n. 24
0
        public MainWindow()
        {
            InitializeComponent();

            _dictionary = new SymbolDictionary();

            SymbolDictionary.Text        = _dictionary.Content;
            VisinerRadioButton.IsChecked = true;
            EncryptionTab.Focus();
        }
        public static SymbolViewModelWrapper LoadSymbolWrapper()
        {
            // Create a new MilitarySymbolDictionary instance
            MilitarySymbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);

            var swRoot = new SymbolViewModelWrapper();
            swRoot = swRoot.Load(@".\data\oob\oobexample.xml");

            return swRoot;
        }
        public void Set_WithNoValue_RemovesFromDictionary()
        {
            var symbol = new Symbol<int>();
            var innerDictionary = new Dictionary<ISymbol, object> { {symbol, 42}};
            var dictionary = new SymbolDictionary(innerDictionary);

            dictionary.Set(symbol, Maybe<int>.NoValue);

            Assert.AreEqual(0, innerDictionary.Count);
        }
Esempio n. 27
0
        public void LoadMBTUSDJPY()
        {
            string           fileName   = @"..\..\Platform\TickZoomTesting\Startup\dictionary.tzdict";
            SymbolDictionary dictionary = SymbolDictionary.Create(new StreamReader(fileName));
            SymbolProperties properties = dictionary.Get("USD/JPY");
            InstrumentImpl   instrument = InstrumentImpl.Get("USD/JPY");

            Assert.AreEqual(instrument.DepthIncrement, properties.Level2Increment);
            Assert.AreEqual(instrument.LotSize, properties.Level2LotSize);
            Assert.AreEqual(instrument.LotSizeDomLimit, properties.Level2LotSizeMinimum);
        }
        public static SymbolViewModelWrapper LoadSymbolWrapper()
        {
            // Create a new MilitarySymbolDictionary instance
            MilitarySymbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);

            var swRoot = new SymbolViewModelWrapper();

            swRoot = swRoot.Load(@".\data\oob\oobexample.xml");

            return(swRoot);
        }
        public void Set_ValueTwice_ReturnsSecondValue()
        {
            var symbol = new Symbol<int>();
            var innerDictionary = new Dictionary<ISymbol, object> { { symbol, 42 } };
            var dictionary = new SymbolDictionary(innerDictionary);

            dictionary.Set(symbol, 7);
            dictionary.Set(symbol, 42);

            Assert.AreEqual(1, innerDictionary.Count);
            Assert.AreEqual(42, (int)innerDictionary[symbol]);
        }
Esempio n. 30
0
        public string GetYaxisSymbol(string symbolname)
        {
            string retval;

            retval = SymbolDictionary.GetSymbolYAxis(symbolname);
            if (retval == "")
            {
                retval = string.Empty;
            }

            return(retval);
        }
Esempio n. 31
0
        public string TranslateSymbolToHelpText(string symbolname, out string helptext, out XDFCategories category, out XDFSubCategory subcategory)
        {
            if (symbolname.EndsWith("!"))
            {
                symbolname = symbolname.Substring(0, symbolname.Length - 1);
            }
            helptext    = "";
            category    = XDFCategories.Undocumented;
            subcategory = XDFSubCategory.Undocumented;
            string description = helptext = SymbolDictionary.GetSymbolDescription(symbolname);

            return(description);
        }
        private async void Init()
        {
            // Wait until all layers are loaded
            await MyMapView.LayersLoadedAsync();

            bool isSymbolDictionaryInitialized = false;

            try
            {
                // Create a new SymbolDictionary instance
                _symbolDictionary             = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
                isSymbolDictionaryInitialized = true;
            }
            catch { }

            if (!isSymbolDictionaryInitialized)
            {
                MessageBox.Show("Failed to create symbol dictionary.", "Symbol Dictionary Search Sample");
                return;
            }

            // Collection of strings to hold the selected symbol dictionary keywords
            SelectedKeywords = new ObservableCollection <string>();

            // Remove any empty strings space from keywords
            _keywords = _symbolDictionary.Keywords.OrderBy(k => k).ToList();
            _keywords = _keywords.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

            // Remove any empty strings space from categories
            _categories = new[] { "" }.Concat(_symbolDictionary.Filters["CATEGORY"]);
            Categories  = _categories.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct();

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection <SymbolViewModel>();

            // Set the image size
            _imageSize = 64;

            // Get reference to MessageLayer to use with messages
            _messageLayer = MyMapView.Map.Layers.OfType <MessageLayer>().First();

            // Fire initial search to populate the results with all symbols
            Search();

            // Enable the UI
            btnSearch.IsEnabled = true;

            // Set the DataContext for binding
            DataContext = this;
        }
        private async void Init()
        {
            // Wait until all layers are loaded
            await MyMapView.LayersLoadedAsync();

            bool isSymbolDictionaryInitialized = false;
            try
            {
                // Create a new SymbolDictionary instance 
                _symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
                isSymbolDictionaryInitialized = true;
            }
            catch { }

            if (!isSymbolDictionaryInitialized)
            {
                MessageBox.Show("Failed to create symbol dictionary.", "Symbol Dictionary Search Sample");
                return;
            }

            // Collection of strings to hold the selected symbol dictionary keywords
            SelectedKeywords = new ObservableCollection<string>();

            // Remove any empty strings space from keywords
            _keywords = _symbolDictionary.Keywords.OrderBy(k => k).ToList();
            _keywords = _keywords.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

            // Remove any empty strings space from categories
            _categories = new[] { "" }.Concat(_symbolDictionary.Filters["CATEGORY"]);
            Categories = _categories.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct();

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection<SymbolViewModel>();

            // Set the image size
            _imageSize = 64;

            // Get reference to MessageLayer to use with messages
            _messageLayer = MyMapView.Map.Layers.OfType<MessageLayer>().First();

            // Fire initial search to populate the results with all symbols
            Search();

            // Enable the UI
            btnSearch.IsEnabled = true;

            // Set the DataContext for binding
            DataContext = this;
        }
Esempio n. 34
0
        public ParsersLexer()
        {
            foreach (var field in typeof(ParsersLexer).GetFields())
            {
                if (field.FieldType != typeof(int))
                {
                    continue;
                }
                field.SetValue(this, _lexer[field.Name]);
            }

            END = _lexer["END"];

            SymbolDictionary = _lexer.SymbolDictionary();
        }
		public SymbolDictionarySearchSample()
		{
			InitializeComponent();
			// Create a new SymbolDictionary instance 
			_symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
			_keywords = _symbolDictionary.Keywords.ToList();

			// Collection of view models for the displayed list of symbols
			Symbols = new ObservableCollection<SymbolViewModel>();

			// Set the DataContext for binding
			DataContext = this;
			// Set the image size
			_imageSize = 40;

			// Get reference to MessageLayer to use with messages
			_messageLayer = mapView.Map.Layers.OfType<MessageLayer>().First();
		}
        protected override void Initialize()
        {
            var properties = new PropertyDictionary(3, checkExistingKeys: false)
            {
                ["from"]    = new PropertyDescriptor(new PropertyDescriptor(new ClrFunctionInstance(Engine, "from", From, 1, PropertyFlag.Configurable), PropertyFlag.NonEnumerable)),
                ["isArray"] = new PropertyDescriptor(new PropertyDescriptor(new ClrFunctionInstance(Engine, "isArray", IsArray, 1), PropertyFlag.NonEnumerable)),
                ["of"]      = new PropertyDescriptor(new PropertyDescriptor(new ClrFunctionInstance(Engine, "of", Of, 0, PropertyFlag.Configurable), PropertyFlag.NonEnumerable))
            };

            SetProperties(properties);

            var symbols = new SymbolDictionary(1)
            {
                [GlobalSymbolRegistry.Species] = new GetSetPropertyDescriptor(get: new ClrFunctionInstance(Engine, "get [Symbol.species]", Species, 0, PropertyFlag.Configurable), set: Undefined, PropertyFlag.Configurable),
            };

            SetSymbols(symbols);
        }
Esempio n. 37
0
        public SymbolDictionarySearchSample()
        {
            InitializeComponent();
            // Create a new SymbolDictionary instance
            _symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
            _keywords         = _symbolDictionary.Keywords.ToList();

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection <SymbolViewModel>();

            // Set the DataContext for binding
            DataContext = this;
            // Set the image size
            _imageSize = 40;

            // Get reference to MessageLayer to use with messages
            _messageLayer = mapView.Map.Layers.OfType <MessageLayer>().First();
        }
        protected override void Initialize()
        {
            var properties = new PropertyDictionary(2, checkExistingKeys: false)
            {
                ["name"] = new PropertyDescriptor("Map", PropertyFlag.Configurable),
                ["next"] = new PropertyDescriptor(new ClrFunctionInstance(Engine, "next", Next, 0, PropertyFlag.Configurable), true, false, true)
            };

            SetProperties(properties);

            if (_name != null)
            {
                var symbols = new SymbolDictionary(1)
                {
                    [GlobalSymbolRegistry.ToStringTag] = new PropertyDescriptor(_name, PropertyFlag.Configurable)
                };
                SetSymbols(symbols);
            }
        }
Esempio n. 39
0
        protected override void Initialize()
        {
            const PropertyFlag lengthFlags = PropertyFlag.Configurable;
            var properties = new PropertyDictionary(3, checkExistingKeys: false)
            {
                ["byteLength"]  = new GetSetPropertyDescriptor(new ClrFunctionInstance(_engine, "get byteLength", ByteLength, 0, lengthFlags), Undefined, PropertyFlag.Configurable),
                ["constructor"] = new PropertyDescriptor(_constructor, PropertyFlag.NonEnumerable),
                ["slice"]       = new PropertyDescriptor(new ClrFunctionInstance(Engine, "slice", Slice, 2, lengthFlags), PropertyFlag.Configurable | PropertyFlag.Writable)
            };

            SetProperties(properties);

            var symbols = new SymbolDictionary(1)
            {
                [GlobalSymbolRegistry.ToStringTag] = new PropertyDescriptor("ArrayBuffer", PropertyFlag.Configurable)
            };

            SetSymbols(symbols);
        }
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Before initializing the ArcGIS Runtime first
            // set the ArcGIS Runtime license by providing the license string
            // obtained from the License Viewer tool.

            // ArcGISRuntime.SetLicense("TODO: Place the License String in here");

            // Initialize the ArcGIS Runtime before any components are created.
            try
            {
                ArcGISRuntime.Initialize();

                string sidc = "SFGAUCIL--AA---";
                if (e.Args.Length != 0)
                {
                    sidc = e.Args[0];
                }

                SymbolDictionary sd = new SymbolDictionary(SymbolDictionaryType.Mil2525C);

                const int exportSize = 128;

                System.Windows.Media.ImageSource export = sd.GetSymbolImage(sidc, exportSize, exportSize);

                System.Windows.Media.Imaging.WriteableBitmap bi = export as System.Windows.Media.Imaging.WriteableBitmap;

                SaveAsPng(sidc + ".png", bi);

                // Exit application
                this.Shutdown();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private async void Init()
        {
            // Wait until all layers are loaded
            await MyMapView.LayersLoadedAsync();

			bool isSymbolDictionaryInitialized = false;
			try
			{
				// Create a new SymbolDictionary instance 
				_symbolDictionary = new SymbolDictionary(SymbolDictionaryType.Mil2525c);
				isSymbolDictionaryInitialized = true;
			}
			catch { }

			if (!isSymbolDictionaryInitialized)
			{
				await new MessageDialog("Failed to create symbol dictionary.", "Symbol Dictionary Search Sample").ShowAsync();
				return;
			}

            // Remove any empty strings space from keywords
            _keywords = _symbolDictionary.Keywords.OrderBy(k => k).ToList();
            _keywords = _keywords.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

            // Collection of view models for the displayed list of symbols
            Symbols = new ObservableCollection<SymbolViewModel>();

            // Set the DataContext for binding
            DataContext = this;

            // Set the image size
            _imageSize = 64;

            // Get reference to MessageLayer to use with messages
            _messageLayer = MyMapView.Map.Layers.OfType<MessageLayer>().First();
        }
Esempio n. 42
0
 private void EnsureDictionary(int id) {
     while (_dicts.Count <= id) {
         _dicts.Add(null);
     }
     if (_dicts[id] == null) {
         _dicts[id] = new SymbolDictionary();
     }
 }
        public void TryGet_WithEmptyDictionaryAndUntypedSymbol_ReturnsNoValue()
        {
            var symbol = new Symbol();
            var dictionary = new SymbolDictionary();

            Assert.IsTrue(dictionary.TryGet<int>(symbol) == Maybe<int>.NoValue);
        }