Beispiel #1
0
        internal SemanticInfo(
            TypeSymbol type,
            Conversion conversion,
            TypeSymbol convertedType,
            ReadOnlyArray <Symbol> symbols,
            LookupResultKind resultKind,
            ReadOnlyArray <MethodSymbol> methodGroup,
            ConstantValue constantValue)
        {
            // When constructing the result for the Caas API, we expose the underlying symbols that
            // may have been hidden under error type, if the error type was immediate. We will
            // expose error types that were constructed, or type parameters of constructed types.
            this.Type               = type.GetNonErrorGuess() ?? type;
            this.ConvertedType      = convertedType.GetNonErrorGuess() ?? convertedType;
            this.ImplicitConversion = conversion;

            this.symbols    = symbols;
            this.resultKind = resultKind;
            if (!symbols.Any())
            {
                this.resultKind = LookupResultKind.Empty;
            }

            this.MethodGroup   = methodGroup;
            this.constantValue = constantValue;
        }
Beispiel #2
0
        public static void RemoveUnusedBindingGroups(SerializedProperty binding, ReadOnlyArray <InputControlScheme> controlSchemes)
        {
            var groupsProperty = binding.FindPropertyRelative(nameof(InputBinding.m_Groups));

            groupsProperty.stringValue = string.Join(InputBinding.kSeparatorString,
                                                     groupsProperty.stringValue
                                                     .Split(InputBinding.Separator)
                                                     .Where(g => controlSchemes.Any(c => c.bindingGroup.Equals(g, StringComparison.InvariantCultureIgnoreCase))));
        }
Beispiel #3
0
        public AssemblyResolver(
            ReadOnlyArray <string> searchPaths,
            Func <string, string> getFullPath,
            Func <ProcessorArchitecture, bool> architectureFilter,
            CultureInfo preferredCulture)
        {
            Contract.ThrowIfTrue(searchPaths.IsNull);
            Contract.ThrowIfTrue(searchPaths.Any(p => string.IsNullOrEmpty(p)));

            this.searchPaths        = searchPaths;
            this.getFullPath        = getFullPath ?? FileUtilities.TryGetFullPath;
            this.architectureFilter = architectureFilter;
            this.preferredCulture   = preferredCulture;
        }
        public AssemblyResolver(
            ReadOnlyArray<string> searchPaths,
            Func<string, string> getFullPath,
            Func<ProcessorArchitecture, bool> architectureFilter,
            CultureInfo preferredCulture)
        {
            Contract.ThrowIfTrue(searchPaths.IsNull);
            Contract.ThrowIfTrue(searchPaths.Any(p => string.IsNullOrEmpty(p)));

            this.searchPaths = searchPaths;
            this.getFullPath = getFullPath ?? FileUtilities.TryGetFullPath;
            this.architectureFilter = architectureFilter;
            this.preferredCulture = preferredCulture;
        }
        internal SemanticInfo(
            TypeSymbol type,
            Conversion conversion,
            TypeSymbol convertedType,
            ReadOnlyArray<Symbol> symbols,
            LookupResultKind resultKind,
            ReadOnlyArray<MethodSymbol> methodGroup,
            ConstantValue constantValue)
        {
            // When constructing the result for the Caas API, we expose the underlying symbols that
            // may have been hidden under error type, if the error type was immediate. We will
            // expose error types that were constructed, or type parameters of constructed types.
            this.Type = type.GetNonErrorGuess() ?? type;
            this.ConvertedType = convertedType.GetNonErrorGuess() ?? convertedType;
            this.ImplicitConversion = conversion;

            this.symbols = symbols;
            this.resultKind = resultKind;
            if (!symbols.Any())
            {
                this.resultKind = LookupResultKind.Empty;
            }

            this.MethodGroup = methodGroup;
            this.constantValue = constantValue;
        }
Beispiel #6
0
        private BoundValueType EmitMethodArgumentsAndGenerics(MethodInfo method, ReadOnlyArray<BoundCallArgument> arguments, ReadOnlyArray<BoundExpression> generics)
        {
            bool needWriteBack = arguments.Any(p => p.IsRef && p.Expression.IsAssignable());

            // Load the arguments array.

            LocalBuilder arrayLocal = null;

            if (arguments.Count > 0 || generics.Count > 0)
            {
                int count = arguments.Count;
                if (generics.Count > 0)
                    count++;

                // Create the array to hold the arguments.
                IL.EmitConstant(count);
                IL.Emit(OpCodes.Newarr, typeof(object));

                // Emit store for the elements.
                EmitArrayElementsStore(arguments.Select(p => p.Expression));

                // We smuggle the generic arguments into the last entry of the
                // arguments array. If we have generic arguments, create a
                // JsGenericArguments object to hold them and put it at the end
                // of the array.

                if (generics.Count > 0)
                {
                    // Dup the array reference for the Stelem. We're going to leave
                    // the array reference on the stack.
                    IL.Emit(OpCodes.Dup);
                    // Emit the index the item is at.
                    IL.EmitConstant(count - 1);

                    // Emit the array to hold the generic arguments.
                    IL.EmitConstant(generics.Count);
                    IL.Emit(OpCodes.Newarr, typeof(object));
                    // Store the generic arguments.
                    EmitArrayElementsStore(generics);
                    // Emit the JsGenericArguments object.
                    IL.Emit(OpCodes.Newobj, _genericArgumentsConstructor);

                    // Store the generic arguments in the array.
                    IL.Emit(OpCodes.Stelem_Ref);
                }

                // If we're doing a write back, we need to hold on to a reference
                // to the array, so dup the stack element here and store it in
                // a local.

                if (needWriteBack)
                {
                    arrayLocal = IL.DeclareLocal(typeof(object[]));
                    IL.Emit(OpCodes.Dup);
                    IL.Emit(OpCodes.Stloc, arrayLocal);
                }
            }
            else
            {
                IL.Emit(OpCodes.Ldsfld, _emptyObjectArray);
            }

            // And execute the method.

            IL.EmitCall(method);

            // The result is now on the stack, which we leave there as the result
            // of this emit.

            if (needWriteBack)
            {
                // We need to read the arguments back for when the ExecuteFunction
                // has out parameters for native calls.

                for (int i = 0; i < arguments.Count; i++)
                {
                    var argument = arguments[i];

                    if (!argument.IsRef || !argument.Expression.IsAssignable())
                        continue;

                    var valueExpression = new BoundEmitExpression(
                        BoundValueType.Unknown,
                        () =>
                        {
                            // Load the argument from the array.
                            IL.Emit(OpCodes.Ldloc, arrayLocal);
                            IL.EmitConstant(i);
                            IL.Emit(OpCodes.Ldelem_Ref);
                        }
                    );

                    if (argument.Expression.Kind == BoundKind.GetMember)
                    {
                        var getMember = (BoundGetMember)argument.Expression;

                        EmitSetMember(getMember.Expression, getMember.Index, valueExpression);
                    }
                    else
                    {
                        var getVariable = (BoundGetVariable)argument.Expression;

                        EmitSetVariable((IBoundWritable)getVariable.Variable, valueExpression);
                    }
                }
            }

            return BoundValueType.Object;
        }