Пример #1
0
 private void EmitStoreLocalVariable(ILocal variableIndex, ILocal value)
 {
     il.Arguments.LoadLocals();
     variableIndex.Load();
     value.Load();
     il.Emit(OpCodes.Stelem_I2);
 }
 public void RemoveItem(ILocal local)
 {
     if (m_localList.Contains(local))
     {
         m_localList.Remove(local);
     }
 }
Пример #3
0
        public void EmitStoreVariable(Variable variable, ILocal value, bool indirect = false, bool reuse = false)
        {
            switch (variable.Kind)
            {
            case VariableKind.Stack:
                if (indirect && reuse)
                {
                    throw new ZCompilerException("Cannot reuse an indirect stack write.");
                }

                if (!reuse)
                {
                    EmitPushStack(value, indirect);
                }
                break;

            case VariableKind.Local:
                EmitStoreLocalVariable(variable.Index, value);
                break;

            case VariableKind.Global:
                EmitStoreGlobalVariable(variable.Index, value);
                break;
            }

            if (reuse)
            {
                value.Load();
            }
        }
 public void AddItem(ILocal local)
 {
     if (!m_localList.Contains(local))
     {
         m_localList.Add(local);
     }
 }
Пример #5
0
 /// <inheritdoc/>
 public IEmitter DeclareLocal(Type localType, string localName, bool pinned, out ILocal local)
 {
     local = null;
     this.emitter?.DeclareLocal(localType, localName, out local);
     this.debugOutput.WriteLineColor(ConsoleColor.Yellow, "Local - [{0}] {1} ({2})", this.index++, localType.Name, localName);
     return(this);
 }
Пример #6
0
        /// <inheritdoc/>
        public IEmitter DeclareLocal(ILocal local)
        {
            var actualLocal = this.ilGen.DeclareLocal(local.LocalType, local.IsPinned);

            ((IAdaptedLocal)local).Local = actualLocal;
            return(this);
        }
Пример #7
0
 /// <summary>
 /// The Local Search API lets you send a search query to Bing and get back
 /// search results that include local businesses such as restaurants, hotels,
 /// retail stores, or other local businesses. The query can specify the name of
 /// the local business or it can ask for a list (for example, restaurants near
 /// me).
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='query'>
 /// The user's search term.
 /// </param>
 /// <param name='acceptLanguage'>
 /// A comma-delimited list of one or more languages to use for user interface
 /// strings. The list is in decreasing order of preference. For additional
 /// information, including expected format, see
 /// [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This
 /// header and the setLang query parameter are mutually exclusive; do not
 /// specify both. If you set this header, you must also specify the cc query
 /// parameter. Bing will use the first supported language it finds from the
 /// list, and combine that language with the cc parameter value to determine
 /// the market to return results for. If the list does not include a supported
 /// language, Bing will find the closest language and market that supports the
 /// request, and may use an aggregated or default market for the results
 /// instead of a specified one. You should use this header and the cc query
 /// parameter only if you specify multiple languages; otherwise, you should use
 /// the mkt and setLang query parameters. A user interface string is a string
 /// that's used as a label in a user interface. There are very few user
 /// interface strings in the JSON response objects. Any links in the response
 /// objects to Bing.com properties will apply the specified language.
 /// </param>
 /// <param name='pragma'>
 /// By default, Bing returns cached content, if available. To prevent Bing from
 /// returning cached content, set the Pragma header to no-cache (for example,
 /// Pragma: no-cache).
 /// </param>
 /// <param name='userAgent'>
 /// The user agent originating the request. Bing uses the user agent to provide
 /// mobile users with an optimized experience. Although optional, you are
 /// strongly encouraged to always specify this header. The user-agent should be
 /// the same string that any commonly used browser would send. For information
 /// about user agents, see [RFC
 /// 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
 /// </param>
 /// <param name='clientId'>
 /// Bing uses this header to provide users with consistent behavior across Bing
 /// API calls. Bing often flights new features and improvements, and it uses
 /// the client ID as a key for assigning traffic on different flights. If you
 /// do not use the same client ID for a user across multiple requests, then
 /// Bing may assign the user to multiple conflicting flights. Being assigned to
 /// multiple conflicting flights can lead to an inconsistent user experience.
 /// For example, if the second request has a different flight assignment than
 /// the first, the experience may be unexpected. Also, Bing can use the client
 /// ID to tailor web results to that client ID’s search history, providing a
 /// richer experience for the user. Bing also uses this header to help improve
 /// result rankings by analyzing the activity generated by a client ID. The
 /// relevance improvements help with better quality of results delivered by
 /// Bing APIs and in turn enables higher click-through rates for the API
 /// consumer. IMPORTANT: Although optional, you should consider this header
 /// required. Persisting the client ID across multiple requests for the same
 /// end user and device combination enables 1) the API consumer to receive a
 /// consistent user experience, and 2) higher click-through rates via better
 /// quality of results from the Bing APIs. Each user that uses your application
 /// on the device must have a unique, Bing generated client ID. If you do not
 /// include this header in the request, Bing generates an ID and returns it in
 /// the X-MSEdge-ClientID response header. The only time that you should NOT
 /// include this header in a request is the first time the user uses your app
 /// on that device. Use the client ID for each Bing API request that your app
 /// makes for this user on the device. Persist the client ID. To persist the ID
 /// in a browser app, use a persistent HTTP cookie to ensure the ID is used
 /// across all sessions. Do not use a session cookie. For other apps such as
 /// mobile apps, use the device's persistent storage to persist the ID. The
 /// next time the user uses your app on that device, get the client ID that you
 /// persisted. Bing responses may or may not include this header. If the
 /// response includes this header, capture the client ID and use it for all
 /// subsequent Bing requests for the user on that device. If you include the
 /// X-MSEdge-ClientID, you must not include cookies in the request.
 /// </param>
 /// <param name='clientIp'>
 /// The IPv4 or IPv6 address of the client device. The IP address is used to
 /// discover the user's location. Bing uses the location information to
 /// determine safe search behavior. Although optional, you are encouraged to
 /// always specify this header and the X-Search-Location header. Do not
 /// obfuscate the address (for example, by changing the last octet to 0).
 /// Obfuscating the address results in the location not being anywhere near the
 /// device's actual location, which may result in Bing serving erroneous
 /// results.
 /// </param>
 /// <param name='location'>
 /// A semicolon-delimited list of key/value pairs that describe the client's
 /// geographical location. Bing uses the location information to determine safe
 /// search behavior and to return relevant local content. Specify the key/value
 /// pair as &lt;key&gt;:&lt;value&gt;. The following are the keys that you use
 /// to specify the user's location. lat (required): The latitude of the
 /// client's location, in degrees. The latitude must be greater than or equal
 /// to -90.0 and less than or equal to +90.0. Negative values indicate southern
 /// latitudes and positive values indicate northern latitudes. long (required):
 /// The longitude of the client's location, in degrees. The longitude must be
 /// greater than or equal to -180.0 and less than or equal to +180.0. Negative
 /// values indicate western longitudes and positive values indicate eastern
 /// longitudes. re (required): The radius, in meters, which specifies the
 /// horizontal accuracy of the coordinates. Pass the value returned by the
 /// device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m
 /// for cell tower triangulation, and 18,000m for reverse IP lookup. ts
 /// (optional): The UTC UNIX timestamp of when the client was at the location.
 /// (The UNIX timestamp is the number of seconds since January 1, 1970.) head
 /// (optional): The client's relative heading or direction of travel. Specify
 /// the direction of travel as degrees from 0 through 360, counting clockwise
 /// relative to true north. Specify this key only if the sp key is nonzero. sp
 /// (optional): The horizontal velocity (speed), in meters per second, that the
 /// client device is traveling. alt (optional): The altitude of the client
 /// device, in meters. are (optional): The radius, in meters, that specifies
 /// the vertical accuracy of the coordinates. Specify this key only if you
 /// specify the alt key. Although many of the keys are optional, the more
 /// information that you provide, the more accurate the location results are.
 /// Although optional, you are encouraged to always specify the user's
 /// geographical location. Providing the location is especially important if
 /// the client's IP address does not accurately reflect the user's physical
 /// location (for example, if the client uses VPN). For optimal results, you
 /// should include this header and the X-MSEdge-ClientIP header, but at a
 /// minimum, you should include this header.
 /// </param>
 /// <param name='countryCode'>
 /// A 2-character country code of the country where the results come from. This
 /// API supports only the United States market. If you specify this query
 /// parameter, it must be set to us. If you set this parameter, you must also
 /// specify the Accept-Language header. Bing uses the first supported language
 /// it finds from the languages list, and combine that language with the
 /// country code that you specify to determine the market to return results
 /// for. If the languages list does not include a supported language, Bing
 /// finds the closest language and market that supports the request, or it may
 /// use an aggregated or default market for the results instead of a specified
 /// one. You should use this query parameter and the Accept-Language query
 /// parameter only if you specify multiple languages; otherwise, you should use
 /// the mkt and setLang query parameters. This parameter and the mkt query
 /// parameter are mutually exclusive—do not specify both.
 /// </param>
 /// <param name='market'>
 /// The market where the results come from. You are strongly encouraged to
 /// always specify the market, if known. Specifying the market helps Bing route
 /// the request and return an appropriate and optimal response. This parameter
 /// and the cc query parameter are mutually exclusive—do not specify both.
 /// </param>
 /// <param name='localCategories'>
 /// comma-delimiated list of business categories to search for. Supported
 /// categories can be high-level such as EatDrink, Shop, SeeDo.
 /// </param>
 /// <param name='localCircularView'>
 /// Preferred location to search around, expressed as Latitude, longitude and
 /// radius in meters. For example 47.61503,-122.1719,5000. Note that circular
 /// view should only be used to indicate a search around a point on the map,
 /// not as an approximation for a view port of a map rectangle.
 /// </param>
 /// <param name='localMapView'>
 /// Preferred bounding box for results, specified in NW_latitude, NW_Longitude,
 /// SE_Latitude, SE_Longitude format. For example 47.64,-122.13,47.63,-122.12.
 /// These values are lat, long pairs for the Northwest corner and the Southeast
 /// corner of a rectangle.
 /// </param>
 /// <param name='count'>
 /// Preferred number of results to return. If not specified, then Bing returns
 /// 1-20 of the most relevant results.
 /// </param>
 /// <param name='first'>
 /// First result to return. zero-based. default is 0.
 /// </param>
 /// <param name='responseFormat'>
 /// The media type to use for the response. The following are the possible
 /// case-insensitive values: JSON, JSONLD. The default is JSON. If you specify
 /// JSONLD, the response body includes JSON-LD objects that contain the search
 /// results.
 /// </param>
 /// <param name='safeSearch'>
 /// A filter used to filter adult content. Off: Return webpages with adult
 /// text, images, or videos. Moderate: Return webpages with adult text, but not
 /// adult images or videos. Strict: Do not return webpages with adult text,
 /// images, or videos. The default is Moderate. If the request comes from a
 /// market that Bing's adult policy requires that safeSearch is set to Strict,
 /// Bing ignores the safeSearch value and uses Strict. If you use the site:
 /// query operator, there is the chance that the response may contain adult
 /// content regardless of what the safeSearch query parameter is set to. Use
 /// site: only if you are aware of the content on the site and your scenario
 /// supports the possibility of adult content. Possible values include: 'Off',
 /// 'Moderate', 'Strict'
 /// </param>
 /// <param name='setLang'>
 /// The language to use for user interface strings. Specify the language using
 /// the ISO 639-1 2-letter language code. For example, the language code for
 /// English is EN. The default is EN (English). Although optional, you should
 /// always specify the language. Typically, you set setLang to the same
 /// language specified by mkt unless the user wants the user interface strings
 /// displayed in a different language. This parameter and the Accept-Language
 /// header are mutually exclusive; do not specify both. A user interface string
 /// is a string that's used as a label in a user interface. There are few user
 /// interface strings in the JSON response objects. Also, any links to Bing.com
 /// properties in the response objects apply the specified language.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SearchResponse> SearchAsync(this ILocal operations, string query, string acceptLanguage = default(string), string pragma = default(string), string userAgent = default(string), string clientId = default(string), string clientIp = default(string), string location = default(string), string countryCode = default(string), string market = "en-us", string localCategories = default(string), string localCircularView = default(string), string localMapView = default(string), string count = default(string), string first = default(string), IList <string> responseFormat = default(IList <string>), string safeSearch = default(string), string setLang = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.SearchWithHttpMessagesAsync(query, acceptLanguage, pragma, userAgent, clientId, clientIp, location, countryCode, market, localCategories, localCircularView, localMapView, count, first, responseFormat, safeSearch, setLang, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #8
0
 /// <summary>
 /// Adds two unsigned integer values, performs an overflow check, and pushes the result onto the evaluation stack.
 /// </summary>
 /// <param name="emitter">A <see cref="IEmitter"/> instance.</param>
 /// <param name="localValue1">The first local value.</param>
 /// <param name="localValue2">The second local value.</param>
 /// <returns>The <see cref="IEmitter"/> instance.</returns>
 public static IEmitter AddOvfUn(this IEmitter emitter, ILocal localValue1, ILocal localValue2)
 {
     return(emitter
            .LdLoc(localValue1)
            .LdLoc(localValue2)
            .AddOvfUn());
 }
 /// <summary>
 /// Emits the IL to load an array element.
 /// </summary>
 /// <param name="emitter">The <see cref="ILGenerator"/> to use.</param>
 /// <param name="array">The <see cref="LocalBuilder"/> containing the array.</param>
 /// <param name="index">The index of the array to load.</param>
 public static IEmitter EmitLoadArrayElement(this IEmitter emitter, ILocal array, int index)
 {
     return(emitter
            .LdLoc(array)
            .LdcI4(index)
            .LdElemRef());
 }
Пример #10
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        private Local(ILocal originalLocal, StatementBlock homeStatementBlock, int localIndex, LocalBuilder localBuilder)
        {
            m_OriginalLocal      = originalLocal;
            m_HomeStatementBlock = homeStatementBlock;
            m_LocalIndex         = localIndex;
            m_LocalBuilder       = localBuilder;
        }
Пример #11
0
 /// <summary>
 /// Divides two values and pushes the remainder onto the evaluation stack.
 /// </summary>
 /// <param name="emitter">A <see cref="IEmitter"/> instance.</param>
 /// <param name="localValue1">The first local value.</param>
 /// <param name="localValue2">The second local value.</param>
 /// <returns>The <see cref="IEmitter"/> instance.</returns>
 public static IEmitter Rem(this IEmitter emitter, ILocal localValue1, ILocal localValue2)
 {
     return(emitter
            .LdLoc(localValue1)
            .LdLoc(localValue2)
            .Rem());
 }
Пример #12
0
 /// <summary>
 /// Transfers control to a target instruction if two values are equal. (Short form)
 /// </summary>
 /// <param name="emitter">A <see cref="IEmitter"/> instance.</param>
 /// <param name="localValue1">The first value.</param>
 /// <param name="localValue2">The second value.</param>
 /// <param name="target">The target instruction.</param>
 /// <returns>The <see cref="IEmitter"/> instance.</returns>
 public static IEmitter BeqS(this IEmitter emitter, ILocal localValue1, ILocal localValue2, ILabel target)
 {
     return(emitter
            .LdLoc(localValue1)
            .LdLoc(localValue2)
            .BeqS(target));
 }
Пример #13
0
 public static CodeBuilder GenerateLoadAndBox(this ILBuilder il, ILocal local)
 {
     return(() =>
     {
         local.LoadAndBox();
     });
 }
        /// <summary>
        /// Emits a call to the return a status code and result as an <see cref="IActionResult"/>.
        /// </summary>
        /// <param name="emitter">An emitter.</param>
        /// <param name="statusCode">The status code.</param>
        /// <param name="local">A local containg the result.</param>
        /// <param name="localResponse">A local to store the response in.</param>
        /// <returns>The emitter instance.</returns>
        public static IEmitter EmitStatusCodeCall(
            this IEmitter emitter,
            int statusCode,
            ILocal local,
            ILocal localResponse)
        {
            emitter
            .LdArg0()
            .LdcI4(statusCode);

            if (local != null)
            {
                emitter
                .LdLocS(local);
            }
            else
            {
                emitter
                .LdNull();
            }

            return(emitter
                   .CallVirt(StatusCodeWithResultMethod)
                   .StLocS(localResponse));
        }
Пример #15
0
        /// <inheritdoc/>
        public IEmitter DeclareLocal(Type localType, string localName, bool pinned, out ILocal local)
        {
            var actualLocal = this.ilGen.DeclareLocal(localType, pinned);

            local = new LocalAdapter(localName, localType, actualLocal.LocalIndex, pinned, actualLocal);
            return(this);
        }
Пример #16
0
        /// <summary>
        /// Emits IL to create a new instance of a <see cref="ServiceCallExecutedContext"/> and call the service call filter attributes
        /// 'OnExecuted' method.
        /// </summary>
        /// <param name="localAttr">A <see cref="ILocal"/> containing a attribute instance.</param>
        /// <param name="localController">A <see cref="ILocal"/> containing a controller instance.</param>
        /// <param name="localServices">A <see cref="ILocal"/> containing a services instance.</param>
        /// <param name="localResponse">A <see cref="ILocal"/> for any response.</param>
        private void EmitExecuted(ILocal localAttr, ILocal localController, ILocal localServices, ILocal localResponse)
        {
            // Create new instance of attribute and call on executed method.
            this.emitter
            .DeclareLocal <ServiceCallExecutedContext>("executedContext", out ILocal context)
            .DeclareLocal <IActionResult>("executedResponse", out ILocal executedResponse)
            .DefineLabel("executedEnd", out ILabel executedEnd)

            .Comment("== Service Call Filter Executed ==")

            .LdLoc(localController)
            .LdLoc(localServices)
            .Newobj(CtorExecuted)
            .StLocS(context)

            .LdLoc(localAttr)
            .LdLocS(context)
            .CallVirt(OnExecutedMethod)

            .GetProperty("Response", context)
            .StLocS(executedResponse)

            .LdLocS(executedResponse)
            .BrFalseS(executedEnd)
            .Nop()

            .LdLocS(executedResponse)
            .StLocS(localResponse)

            .MarkLabel(executedEnd);
        }
Пример #17
0
        /// <summary>
        /// Emits IL to the 'OnExecuted' method on <see cref="ServiceCallFilterAttribute"/> instances.
        /// </summary>
        /// <param name="localController">A <see cref="ILocal"/> containing a controller instance.</param>
        /// <param name="localServices">A <see cref="ILocal"/> containing a services instance.</param>
        /// <param name="localResponse">A <see cref="ILocal"/> for any response.</param>
        public void EmitExecuted(ILocal localController, ILocal localServices, ILocal localResponse)
        {
            if (this.HasAttributes == false)
            {
                return;
            }

            this.emitter
            .Comment("== Service Call Filter Emit Executed ==")
            .EmitIfNotNullOrEmpty(
                this.localServiceCallAttrs,
                il => il
                .DefineLabel("executedAfterLoop", out ILabel afterLoop)

                .For(
                    this.localServiceCallAttrs,
                    (em, index, item) =>
            {
                this.EmitExecuted(item, localController, localServices, localResponse);

                em
                .LdLoc(localResponse)
                .BrTrue(afterLoop);
            })

                .MarkLabel(afterLoop));
        }
Пример #18
0
 public static CodeBuilder GenerateStore(this ILBuilder il, ILocal local)
 {
     return(() =>
     {
         local.Store();
     });
 }
Пример #19
0
 /// <summary>
 /// Multiplies two integer values, performs an overflow check, and pushes the result onto the evaluation stack.
 /// </summary>
 /// <param name="emitter">A <see cref="IEmitter"/> instance.</param>
 /// <param name="localValue1">The first local value.</param>
 /// <param name="localValue2">The second local value.</param>
 /// <returns>The <see cref="IEmitter"/> instance.</returns>
 public static IEmitter MulOvf(this IEmitter emitter, ILocal localValue1, ILocal localValue2)
 {
     return(emitter
            .LdLoc(localValue1)
            .LdLoc(localValue2)
            .MulOvf());
 }
Пример #20
0
 public void ResetFromScripts()
 {
     foreach (GameObject obj in saveAndLoadScripts)
     {
         ILocal interfaceAcces = obj.GetComponent(typeof(ILocal)) as ILocal;
         interfaceAcces.Reset();
     }
 }
Пример #21
0
        public void EmitSetCursor(ILocal line, ILocal column)
        {
            il.Arguments.LoadMachine();
            line.Load();
            column.Load();

            il.Call(Reflection <CompiledZMachine> .GetMethod("SetCursor", Types.Array <int, int>(), @public: false));
        }
Пример #22
0
        public void CopyArray(IArrayLocal source, IArrayLocal destination, ILocal length)
        {
            source.Load();
            destination.Load();
            length.Load();

            Emit(OpCodes.Call, arrayCopy);
        }
Пример #23
0
 public void EmitLoadDefaultPropertyAddress(ILocal propertyNumber)
 {
     propertyNumber.Load();
     il.Math.Subtract(1);
     il.Math.Multiply(2);
     il.Math.Add(machine.ObjectTableAddress);
     il.Convert.ToUInt16();
 }
Пример #24
0
        public void EmitSetColor(ILocal foreground, ILocal background)
        {
            il.Arguments.LoadMachine();
            foreground.Load();
            background.Load();

            il.Call(Reflection <CompiledZMachine> .GetMethod("SetColors", Types.Array <ZColor, ZColor>(), @public: false));
        }
Пример #25
0
        // not: all of the handlers would be notified
        // only when user polled
        // thus, ensure thread-safety

        private void OnHandleConnected(ILocal remote, Exception e)
        {
            handle.SendDatav(MessageTypeToBuffer(GateMessage.Handshake), uuid.ToByteArray());

            // todo
            // only when adaptor received a ack from gate,
            // then should it notify upper layer,
            // that connected
        }
Пример #26
0
        protected override void PostOperation(ILocal result, ILBuilder il, ICompiler compiler)
        {
            result.Load();
            compiler.EmitLoadOperand(op2);
            il.Convert.ToInt16();

            Compare(il);
            compiler.EmitBranch(branch);
        }
Пример #27
0
        public static void Serialize(Stream s, object toSerialize, ILocal local, List <Guid> fullySerialized, bool fullySerializeEverything = false)
        {
            BinaryFormatter  binaryFormatter = new BinaryFormatter();
            StreamingContext c = new StreamingContext(StreamingContextStates.All, new Variables(local, fullySerialized, fullySerializeEverything));

            binaryFormatter.Context = c;

            binaryFormatter.Serialize(s, toSerialize);
        }
Пример #28
0
 public AccountController(IAccount account, IUserProfile userPro, StaffPortalDataContext context, ILocal local, SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager)
 {
     _userPro       = userPro;
     _account       = account;
     _signInManager = signInManager;
     _context       = context;
     _local         = local;
     _userManager   = userManager;
 }
Пример #29
0
 public static T Clone <T>(T toClone, ILocal local) where T : class
 {
     using (MemoryStream ms = new MemoryStream())
     {
         Serialize(ms, toClone, local, null, true);
         ms.Seek(0, SeekOrigin.Begin);
         return(Deserialize(ms, local) as T);
     }
 }
Пример #30
0
        /// <summary>
        /// Reads the number of an object's child, given its 1-based object number.
        /// </summary>
        /// <param name="objNum">The local variable containing the object number.
        /// If null, the object number is retrieved from the top of the evaluation stack.</param>
        private void ReadObjectChild(ILocal objNum = null)
        {
            CalculateObjectAddress(objNum);

            // Add child number offset to the address on the evaluation stack.
            il.Math.Add(machine.ObjectChildOffset);

            ReadObjectNumber();
        }
Пример #31
0
        // not: all of the handlers would be notified
        // only when user polled
        // thus, ensure thread-safety

        private void OnHandleConnected(ILocal remote, Exception e)
        {
            handle.SendDatav(MessageTypeToBuffer(GateMessage.Handshake), uuid.ToByteArray());

            // todo 
            // only when adaptor received a ack from gate,
            // then should it notify upper layer,
            // that connected
        }