Exemplo n.º 1
0
        public IEnumerable <ITypedMemberDescriptor> Get(Specifier d)
        {
            if (_t == null)
            {
                yield break;
            }
            yield break;
#if ENABLE_CSHARP_PROPERTY_PARSING
            foreach (var p in _t.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (!p.CanRead || !p.GetGetMethod(true).IsPublic)
                {
                    continue;
                }

                // we dont support recursion for now ...
                if (_t == p.PropertyType)
                {
                    continue;
                }

                if (p.PropertyType.IsValueType != d.HasFlag(Specifier.ValueType))
                {
                    continue;
                }

                yield return(new PropertyMemberDescriptor(p));
            }
#endif
        }
Exemplo n.º 2
0
 public IEnumerable <ITypedMemberDescriptor> Get(Specifier d)
 {
     if (_t == null)
     {
         yield return(null);
     }
     foreach (var field in _t.GetFields())
     {
         if (field.IsStatic)
         {
             continue;
         }
         if (field.FieldType.IsValueType != d.HasFlag(Specifier.ValueType))
         {
             continue;
         }
         if (field.IsPublic && d.HasFlag(Specifier.Public))
         {
             yield return(new FieldMemberDescriptor(field));
         }
         if (!field.IsPublic && d.HasFlag(Specifier.Private))
         {
             yield return(new FieldMemberDescriptor(field));
         }
     }
 }
Exemplo n.º 3
0
 public Node(CXCursor cursor, CXCursorKind type, Specifier specifier, string name, string full_name, string value, int line, int column)
 {
     m_cursor    = cursor;
     m_kind      = type;
     m_name      = name;
     m_full_name = full_name;
     m_line      = line;
     m_column    = column;
     m_specifier = specifier;
     m_childrens = new List <Node>();
 }
Exemplo n.º 4
0
        public bool IsHomogeneous(Specifier type)
        {
            foreach (var element in contents)
            {
                if (!Shell.Interpreter.Utility.MatchType(element, type))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 5
0
        public List <Specifier> ParseSpecifiers(List <TokenType> specifierCategory)
        {
            List <Specifier> specs = new List <Specifier>();
            Specifier        spec  = TryParseSpecifier(specifierCategory);

            while (spec != null)
            {
                specs.Add(spec);
                spec = TryParseSpecifier(specifierCategory);
            }
            return(specs);
        }
Exemplo n.º 6
0
        public bool IsHomogeneous(Specifier type)
        {
            foreach (var pair in dict)
            {
                if (!Shell.Interpreter.Utility.MatchType(pair.Value, type))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 7
0
        private void AddFakeMarkets(
            List <CreateUpdateMarketsCommandSelection> marketsBuilder,
            Specifier specifier,
            IList <decimal?> selection,
            Dictionary <string, TranslationMarket> currentMarkets,
            string fakeMarketId,
            long originalMarketId
            )
        {
            if (!marketGroups.TryGetValue(Convert.ToInt32(selection[0]), out var selectionTypeId))             // index 0 - outcome_id
            {
                selectionTypeId = Convert.ToInt32(selection[0]);
            }

            var specifiers = specifier == null ? null : new SpecifierCollection(specifier);

            var currentMarketId    = fakeMarketId + (specifier == null ? "" : ":" + specifier.Key + "=" + specifier.Value);
            var currentSelectionId = fakeMarketId + ":" + selectionTypeId + (specifier == null ? "" : ":" + specifier.Key + "=" + specifier.Value);


            // adding market to cache
            currentMarkets.TryAdd(
                currentSelectionId,
                new TranslationMarket()
            {
                Id             = originalMarketId,
                FakeId         = currentMarketId,
                SelectionId    = selectionTypeId,
                SpecifierValue = specifier?.Value
            }
                );

            marketsBuilder.Add
            (
                new CreateUpdateMarketsCommandSelection
                (
                    marketId: currentMarketId,
                    marketTypeId: originalMarketId.ToString(),
                    selectionId: currentSelectionId,

                    specifiers: specifiers,
                    selectionTypeId: selectionTypeId.ToString(),
                    tradingStatus: TradingStatus.Open,
                    selectionTradingStatus: TradingStatus.Open,
                    value: Round2(selection[1]),
                    probability: null
                )
            );
        }
Exemplo n.º 8
0
        public string Description(bool spellOutWhitespace)
        {
            // here be dragons!
            // keep track of:
            // - escaped chars
            // - escape sequences (each having a different description)
            // - codepoint escapes (belongs into above category but kept separate)
            // - and actually boring literal matches
            if (Specifier.Length > 1)
            {
                var relevant = Specifier.Substring(1); // skip the damn Backslash at the start
                if (relevant.Length > 1)               // longer sequences
                {
                    if (relevant.StartsWith("u"))
                    {
                        return(string.Format(AssistantResources.AtomDescription_Literal_UnicodePoint, relevant.Substring(1))); //skip u
                    }

                    if (relevant.StartsWith("x"))
                    {
                        return(string.Format(AssistantResources.AtomDescription_Literal_HexCodepoint, relevant.Substring(1))); // skip x
                    }

                    return(string.Format(AssistantResources.AtomDescription_Literal_OctalCodepoint, relevant)); // no format specifier to skip
                }

                if (EscapeLiterals.Contains(relevant[0]))
                {
                    return(string.Format(AssistantResources.AtomDescription_Literal_EscapedLiteral, relevant));
                }

                if (char.IsDigit(relevant[0]))
                {
                    return(string.Format(AssistantResources.AtomDescription_Literal_Backreference, relevant));
                }

                return(_escapeDescriptions[relevant[0]]);
            }

            if (Specifier.Equals("."))
            {
                return(AssistantResources.AtomDescription_Dot);
            }

            return(string.Format(AssistantResources.AtomDescription_Literal_ActualLiteral,
                                 spellOutWhitespace && WhitespaceToString.IsFullySpellingOutApplicable(Specifier, out var spelledOutWhiteSpace)
                    ? spelledOutWhiteSpace
                    : Specifier));
        }
Exemplo n.º 9
0
        //==============================================================================
        /// <summary>
        ///
        /// </summary>
        //==============================================================================
        private void aggregateValues()
        {
            TMainOutputSpecifier Specifier;
            TDDMLValue           requestValue;
            TDDMLValue           outputValue;

            for (int i = 0; i < FOutputs.Count; i++)
            {
                Specifier    = (TMainOutputSpecifier)FOutputs[i];
                requestValue = FRequests[Specifier.iReqIdx];
                outputValue  = Specifier.FindValue(requestValue);
                if (outputValue != null)
                {
                    aggregateValue(outputValue, Specifier.valTree);
                }
                else
                {
                    throw (new ApplicationException("Output value not found: " + Specifier.sName));
                }
            }
        }
Exemplo n.º 10
0
        static bool MatchObj(VerbParameters param, Mob m, Specifier spec)
        {
            if (spec == Specifier.Wildcard)
            return true;
            if (spec == Specifier.Any)
            return m != null && m != Mob.None;
            if (spec == Specifier.Self)
            return m != null && m.id == param.self.id;

            if (spec == Specifier.None
            && (m == null || m == Mob.None))
            {
            return true;
            }

            return false;
        }
Exemplo n.º 11
0
        public IEnumerable <ITransmitterCommand> Adapt(MessageContext <EventData, TranslationSubscription> context)
        {
            var msg = context.Message;
            var translationState = context.State.PersistableState;
            var translationId    = long.Parse(msg.TranslationId);
            var lineService      = LineService.SportLevel;

            var marketsBuilder = new List <CreateUpdateMarketsCommandSelection>();
            var list           = new List <ITransmitterCommand>();

            var currentMarkets = new Dictionary <string, TranslationMarket>();

            foreach (var market in msg.Extra.Markets)
            {
                var fakeMarketId = $"{lineService}:{msg.TranslationId}:{market.Id}";

                var specifierKey = adapterConfiguration.Specifiers.Total.Contains(market.Id) ? SpecifierKey.Total
                                        : adapterConfiguration.Specifiers.Hcp.Contains(market.Id) ? SpecifierKey.Handicap
                                        : adapterConfiguration.Specifiers.Pointnr.Contains(market.Id) ? SpecifierKey.PointNumber
                                        : null;

                // Outcomes
                if (market.Selections.Any())
                {
                    var arr = market.Selections.ToArray();

                    // Not categorized market with specifiers
                    if (arr.Any(t => t[2].HasValue) && specifierKey == null)
                    {
                        logger.LogWarning($"Uncategorized market with specifiers was detected. MessageId={context.IncomingId}, marketId={market.Id}");

                        continue;                         // to next market
                    }

                    Specifier hcpOldSpecifier = null;

                    for (int i = 0; i < arr.Count(); i++)
                    {
                        Specifier specifier = null;
                        var       item      = arr[i];

                        if (specifierKey != null)
                        {
                            if (i % 2 == 1 && specifierKey == SpecifierKey.Handicap)
                            {
                                specifier = hcpOldSpecifier;
                            }
                            else
                            {
                                specifier = item[2].HasValue ? GetSpecifier(specifierKey, item[2].Value) : null;
                            }
                        }

                        // Creating markets
                        AddFakeMarkets(
                            marketsBuilder,
                            specifier,
                            item,
                            currentMarkets,
                            fakeMarketId,
                            market.Id
                            );

                        hcpOldSpecifier = specifier;
                    }
                }
            }

            // Markets to state
            foreach (var item in currentMarkets)
            {
                translationState.Markets.GetOrAdd(item.Key, item.Value);
            }

            lock (translationState.Markets)
            {
                // Susupensing markets which are left
                foreach (var fakeId in translationState.Markets.Keys.Except(currentMarkets.Select(t => t.Key)))
                {
                    var entry = translationState.Markets[fakeId];

                    marketsBuilder.Add(
                        new CreateUpdateMarketsCommandSelection
                        (
                            marketId: entry.FakeId,
                            marketTypeId: entry.Id.ToString(),
                            selectionId: fakeId,
                            specifiers: entry.SpecifierValue == null
                                                                ? null
                                                                : new SpecifierCollection(GetSpecifier(entry.Id, translationState.Markets[fakeId].SpecifierValue, adapterConfiguration)),
                            selectionTypeId: entry.SelectionId.ToString(),
                            tradingStatus: TradingStatus.Suspended,
                            selectionTradingStatus: TradingStatus.Suspended,
                            value: null,
                            probability: null
                        )
                        );
                }
            }

            list.Add(
                new CreateUpdateMarketsCommand(
                    lineService: lineService,
                    gameEventId: msg.TranslationId.ToString(),
                    receivedOn: context.ReceivedOn,
                    incomingId: context.IncomingId,
                    selections: marketsBuilder.ToImmutableArray(),
                    extraAttributes: null
                    )
                );

            context.State.SaveState();
            return(list);
        }
Exemplo n.º 12
0
 public override int GetHashCode()
 {
     return(Specifier.GetHashCode());
 }
Exemplo n.º 13
0
        void ParseTypeDefinition(List<INamespaceDeclarationMember> members, List<ITypeDeclarationMember> globalMembers, TokenSet followers, bool isRecord)
        {
            var noSpecifiers = new Specifier[0];
              var name = this.ParseNameDeclaration(true);
              var loc = name.SourceLocation;
              var name0 = name.Name.Value;
              var mangledName = new VccNameDeclaration(this.GetNameFor("_vcc_math_type_" + name0), loc);

              var tpMembers = new List<ITypeDeclarationMember>();
              var strct = new VccStructDeclaration(mangledName, tpMembers, noSpecifiers, loc);
              var tp = new VccNamedTypeExpression(new VccSimpleName(mangledName, mangledName.SourceLocation));

              UpdateForwardDeclaration(members, strct);

              if (isRecord) {
            List<FieldDeclaration>/*?*/ savedSpecificationFields = this.currentSpecificationFields;
            List<TypeInvariant>/*?*/ savedTypeInvariants = this.currentTypeInvariants;
            this.currentSpecificationFields = null;
            this.currentTypeInvariants = null;
            SourceLocationBuilder sctx = this.GetSourceLocationBuilderForLastScannedToken();

            this.ParseRestOfTypeDeclaration(sctx, members, tp.Expression, tpMembers, followers);
            if (this.currentToken == Token.EndOfFile) {
              ISourceLocation errorLocation = this.scanner.SourceLocationOfLastScannedToken;
              this.HandleError(errorLocation, Error.MissingSemicolonAfterStruct, "end-of-file");
            }
            this.SkipTo(followers);
            this.AssociateTypeWithTypeContract(strct, this.currentSpecificationFields, this.currentTypeInvariants, this.InSpecCode);

            this.currentSpecificationFields = savedSpecificationFields;
            this.currentTypeInvariants = savedTypeInvariants;
              } else {
            strct.IsAbstractType = true;
            /*
            var fld = new FieldDefinition(new List<Specifier>(), 0, VccCompilationHelper.GetBigIntType(nameTable),
                                      new VccNameDeclaration(this.GetNameFor("_vcc_dummy"), loc), null, true, loc);
            tpMembers.Add(fld);
            */
              }

              var typedefDecl = new TypedefDeclaration(tp, name, loc);
              this.RegisterTypedef(name.Value, typedefDecl);
              globalMembers.Add(typedefDecl);
        }
Exemplo n.º 14
0
        void ParseDataTypeDefinition(List<INamespaceDeclarationMember> members, List<ITypeDeclarationMember> globalMembers, TokenSet followers)
        {
            var noSpecifiers = new Specifier[0];
              var name = this.ParseNameDeclaration(true);
              var loc = name.SourceLocation;
              var mangledName = new VccNameDeclaration(this.GetNameFor("_vcc_math_type_" + name.Name.Value), loc);
              var ctornames = new List<FunctionDeclaration>();
              var strct = new VccDatatypeDeclaration(mangledName, new List<ITypeDeclarationMember>(), noSpecifiers, ctornames, loc);
              UpdateForwardDeclaration(members, strct);

              var tp = new VccNamedTypeExpression(new VccSimpleName(mangledName, mangledName.SourceLocation));

              var typedefDecl = new TypedefDeclaration(tp, name, loc);
              this.RegisterTypedef(name.Value, typedefDecl);
              globalMembers.Add(typedefDecl);

              this.Skip(Token.LeftBrace);

              for (; ; ) {
            SourceLocationBuilder scCtx = this.GetSourceLocationBuilderForLastScannedToken();
            if (this.currentToken != Token.Case)
            {
              this.Skip(this.currentToken == Token.RightBrace ? Token.RightBrace : Token.Case);
              break;
            }
            this.Skip(Token.Case);
            var fname = this.ParseNameDeclaration(true);
            var parmFollowers = followers | Token.RightBrace | Token.Case | Token.Semicolon;
            var parms0 = this.ParseParameterList(parmFollowers);
            this.Skip(Token.RightParenthesis);
            if (this.currentToken == Token.Semicolon)
              this.Skip(Token.Semicolon);
            bool acceptsExtraArguments;
            var parms1 = this.ConvertToParameterDeclarations(parms0, out acceptsExtraArguments);
            var specifiers = new[] { this.CreateAttribute("_vcc_internal__is_datatype_option", "", scCtx) };
            var fdecl = new FunctionDeclaration(acceptsExtraArguments,
                        specifiers, false, CallingConvention.C, TypeMemberVisibility.Public,
                        tp, fname, null, parms1, true, null, scCtx
                    );
            globalMembers.Add(fdecl);
            ctornames.Add(fdecl);
              }

              if (ctornames.Count == 0)
            this.HandleError(Error.EmptySwitch); //TODO use proper error
        }