Beispiel #1
0
        internal IndexStorageVisitor(SnapshotStorageEntry indexedEntry, Snapshot context, MemberIdentifier index)
        {
            _context = context;
            _index   = index;
            var indexedValues = indexedEntry.ReadMemory(context);

            VisitMemoryEntry(indexedValues);

            if (implicitArray != null)
            {
                //TODO replace only undefined values
                indexedEntry.WriteMemoryWithoutCopy(context, new MemoryEntry(implicitArray));
            }

            var forceStrong = indexedEntry.ForceStrong;

            if (_hasOnlyArrays && indexedEntry.HasDirectIdentifier && index.IsDirect)
            {
                //optimization
                forceStrong = true;
            }

            if (_needsTemporaryIndex)
            {
                foreach (var key in indexedEntry.Storages)
                {
                    _indexStorages.Add(new VariableIndexKey(key, _index));
                }
            }

            IndexedValue = new SnapshotStorageEntry(null, forceStrong, _indexStorages.ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// Evaluates all values to string if it is possible and creates index identifier.
        /// </summary>
        /// <param name="entry">Memory entry with all possible values to convert to index.</param>
        /// <param name="isAlwaysLegal">Indicates that there is no compound (forbidden) value.</param>
        /// <returns>Member identifier created from all values of the memory entry.</returns>
        public MemberIdentifier EvaluateToIdentifiers(MemoryEntry entry, out bool isAlwaysLegal)
        {
            var integerValues = new HashSet <IntegerValue>();
            var stringValues  = new HashSet <StringValue>();

            bool isAlwaysConcrete;
            bool isAlwaysInteger;

            Evaluate(entry, integerValues, stringValues, out isAlwaysConcrete,
                     out isAlwaysInteger, out isAlwaysLegal);

            if (isAlwaysConcrete)
            {
                var indices = new HashSet <string>();

                foreach (var integerValue in integerValues)
                {
                    indices.Add(TypeConversion.ToString(integerValue.Value));
                }

                foreach (var stringValue in stringValues)
                {
                    indices.Add(stringValue.Value);
                }

                return(new MemberIdentifier(indices));
            }
            else
            {
                return(MemberIdentifier.getAnyMemberIdentifier());
            }
        }
Beispiel #3
0
 /// <inheritdoc />
 public override MemoryEntry ReadAnyValueIndex(AnyValue value, MemberIdentifier index)
 {
     // TODO: Copy info
     if (value is AnyStringValue)
     {
         // Element of string is one charachter but since PHP has no character type,
         // it returns string with one character. The character do not need to be initialized
         SetWarning("Possibly uninitialized string offset");
         return(new MemoryEntry(Context.AnyStringValue));
     }
     else if ((value is AnyNumericValue) || (value is AnyBooleanValue) || (value is AnyResourceValue))
     {
         SetWarning("Trying to get element of scalar value",
                    AnalysisWarningCause.ELEMENT_OF_NON_ARRAY_VARIABLE);
         return(new MemoryEntry(Context.UndefinedValue));
     }
     else if (value is AnyObjectValue)
     {
         // TODO: This must be error
         SetWarning("Cannot use object as array");
         return(new MemoryEntry(Context.AnyValue));
     }
     else
     {
         // This is case of AnyArrayValue, AnyValue and possibly others.
         // If value is AnyValue, it can be any object too, so it can cause an error.
         Value newValue = Context.AnyValue;
         newValue = FlagsHandler.CopyFlags(value, newValue);
         return(new MemoryEntry(newValue));
     }
 }
Beispiel #4
0
        public void EmitMain()
        {
            var typeId               = new TypeIdentifier(Assembly.EntryPoint.DeclaringType);
            var memberId             = new MemberIdentifier(Translator.TypeInfoProvider, Assembly.EntryPoint);
            var entryPointIdentifier = new QualifiedMemberIdentifier(typeId, memberId);

            var mainExpression = Translator.FunctionCache.GetExpression(entryPointIdentifier);

            var astEmitter  = (AstEmitter)EntryPointAstEmitter;
            var mainEmitter = new AstEmitter(this, Formatter, astEmitter.JSIL, astEmitter.TypeSystem, astEmitter.TypeInfo, astEmitter.Configuration, isTopLevel: true);

            Switch(PrecedingType.TopLevel);

            if (NeedStaticInit)
            {
                Formatter.ConditionalNewLine();
                Formatter.WriteRaw("(invoke \"__static_init\")");
                Formatter.NewLine();
                Formatter.NewLine();
            }

            var body = mainExpression.Body;

            foreach (var stmt in body.Statements)
            {
                mainEmitter.Visit(stmt);
                Formatter.ConditionalNewLine();
            }
        }
Beispiel #5
0
        private void initTaintedVariable(FlowOutputSet outSet, String name)
        {
            outSet.Snapshot.SetMode(SnapshotMode.InfoLevel);

            var TaintedVar = outSet.GetVariable(new VariableIdentifier(name), true);

            var taint = new TaintInfo();

            taint.taint    = new Taint(true);
            taint.priority = new TaintPriority(true);
            taint.tainted  = true;

            var Taint = outSet.CreateInfo(taint);

            //TaintedVar.WriteMemory(outSet.Snapshot, new MemoryEntry(Taint));

            var entry = TaintedVar.ReadIndex(EntryInput.Snapshot, MemberIdentifier.getAnyMemberIdentifier());

            entry.WriteMemory(EntryInput.Snapshot, new MemoryEntry(Taint));

            /*
             * TaintedVar = outSet.GetVariable(new VariableIdentifier(name), true);
             * Taint = outSet.CreateInfo(taint);
             *
             * TaintedVar.WriteMemory(outSet.Snapshot, new MemoryEntry(Taint));*/
        }
Beispiel #6
0
        private IEnumerable <int> ResolveStringIndex(StringValue value, MemberIdentifier Index)
        {
            var NumberIndices = new HashSet <int>();

            foreach (var i in Index.PossibleNames)
            {
                int p;
                if (int.TryParse(i, out p))
                {
                    NumberIndices.Add(p);
                }
                else
                {
                    NumberIndices.Add(0);
                }
            }

            if (NumberIndices.Count == 0)
            {
                for (int i = 0; i < value.Value.Count(); i++)
                {
                    NumberIndices.Add(i);
                }
            }
            return(NumberIndices);
        }
Beispiel #7
0
        /// <inheritdoc />
        protected override ReadWriteSnapshotEntryBase readIndex(SnapshotBase context,
                                                                MemberIdentifier index)
        {
            // TODO: The method should return SnapshotMemoryEntry of read indices

            var snapshot = C(context);
            var allKeys  = new List <Memory.VariableKeyBase>();

            foreach (var value in WrappedEntry.PossibleValues)
            {
                var array = value as AssociativeArray;
                if (array != null)
                {
                    var keys = snapshot.IndexStorages(array, index);
                    // TODO: Use snapshot.ReadValue to read values of every variable key
                    allKeys.AddRange(keys);
                }
                else
                {
                    // TODO: If it is not array, what to do?
                    throw new NotSupportedException("Reading indices on non-arrays is not supported in SnapshotMemoryEntry yet");
                }
            }

            return(new SnapshotStorageEntry(null, ForceStrong, allKeys.ToArray()));
        }
Beispiel #8
0
        public override MemoryEntry ReadAnyValueIndex(AnyValue value, MemberIdentifier index)
        {
            //copy info
            var info    = value.GetInfo <SimpleInfo>();
            var indexed = Context.AnyValue.SetInfo(info);

            return(new MemoryEntry(indexed));
        }
Beispiel #9
0
        public CollectIndexValueVisitor(IndexPathSegment indexSegment, TreeIndexCollector treeIndexCollector, CollectorNode node, bool isMust)
        {
            this.indexSegment       = indexSegment;
            this.treeIndexCollector = treeIndexCollector;
            this.node   = node;
            this.isMust = isMust;

            index = new MemberIdentifier(indexSegment.Names);
        }
Beispiel #10
0
        /// <inheritdoc />
        public override IEnumerable <Value> ReadValueIndex(Value value, MemberIdentifier index)
        {
            if (!(value is UndefinedValue))
            {
                SetWarning("Cannot use operator [] on variable other than string or array", AnalysisWarningCause.CANNOT_ACCESS_FIELD_OPERATOR_ON_NON_ARRAY);
            }

            //reading of index returns undefined value
            yield return(Context.UndefinedValue);
        }
Beispiel #11
0
        /// <inheritdoc />
        public override IEnumerable <Value> WriteValueIndex(Value indexed, MemberIdentifier index, MemoryEntry writtenValue)
        {
            if (!(indexed is UndefinedValue))
            {
                SetWarning("Cannot use operator [] on variable other than string or array", AnalysisWarningCause.CANNOT_ACCESS_FIELD_OPERATOR_ON_NON_ARRAY);
            }

            //we dont want to change indexed value itself
            yield return(indexed);
        }
Beispiel #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadIndexVisitor"/> class.
        /// </summary>
        /// <param name="containingIndex">Index of the containing.</param>
        /// <param name="indexSegment">The index segment.</param>
        /// <param name="locations">The locations.</param>
        public ReadIndexVisitor(MemoryIndex containingIndex, IndexPathSegment indexSegment, ICollection <ValueLocation> locations)
        {
            this.containingIndex = containingIndex;
            this.locations       = locations;

            ContainsUndefinedValue = false;
            ContainsDefinedValue   = false;
            ContainsArrayValue     = false;
            ContainsAnyValue       = false;

            index = new MemberIdentifier(indexSegment.Names);
        }
Beispiel #13
0
        /// <summary>
        /// Create index representation for given index
        /// </summary>
        /// <param name="index">Index which representation is created</param>
        /// <returns>Created index representation</returns>
        private string indexRepresentation(MemberIdentifier index)
        {
            var name = new StringBuilder();

            foreach (var possibleName in index.PossibleNames)
            {
                name.Append(possibleName);
                name.Append(',');
            }

            return(name.ToString());
        }
Beispiel #14
0
        public override IEnumerable <Value> WriteStringIndex(StringValue indexed, MemberIdentifier index, MemoryEntry writtenValue)
        {
            var indexNum    = int.Parse(index.DirectName);
            var writtenChar = writtenValue.PossibleValues.First() as StringValue;

            var result = new StringBuilder(indexed.Value);

            result[indexNum] = writtenChar.Value[0];

            var resultValue = Context.CreateString(result.ToString());

            yield return(resultValue);
        }
Beispiel #15
0
        public static TypeReference SubstituteTypeArgs(ITypeInfoSource typeInfo, TypeReference type, MemberReference member)
        {
            var gp = (type as GenericParameter);

            if (gp != null)
            {
                if (gp.Owner.GenericParameterType == GenericParameterType.Method)
                {
                    var ownerIdentifier  = new MemberIdentifier(typeInfo, (MethodReference)gp.Owner);
                    var memberIdentifier = new MemberIdentifier(typeInfo, (dynamic)member);

                    if (!ownerIdentifier.Equals(memberIdentifier, typeInfo))
                    {
                        return(type);
                    }

                    if (!(member is GenericInstanceMethod))
                    {
                        return(type);
                    }
                }
                else
                {
                    var declaringType = member.DeclaringType.Resolve();
                    // FIXME: Is this right?
                    if (declaringType == null)
                    {
                        return(type);
                    }

                    var ownerResolved = ((TypeReference)gp.Owner).Resolve();
                    // FIXME: Is this right?
                    if (ownerResolved == null)
                    {
                        return(type);
                    }

                    var ownerIdentifier = new TypeIdentifier(ownerResolved);
                    var typeIdentifier  = new TypeIdentifier(declaringType);

                    if (!ownerIdentifier.Equals(typeIdentifier))
                    {
                        return(type);
                    }
                }
            }

            return(TypeAnalysis.SubstituteTypeArgs(type, member));
        }
Beispiel #16
0
        internal IEnumerable <VariableKeyBase> IndexStorages(Value array, MemberIdentifier index)
        {
            var storages = new List <VariableKeyBase>();

            foreach (var indexName in index.PossibleNames)
            {
                //TODO refactor ContainerIndex API
                var containerIndex = CreateIndex(indexName);
                var key            = getIndexStorage(array, containerIndex);

                storages.Add(key);
            }

            return(storages);
        }
Beispiel #17
0
        public T GetMemberInformation <T> (MemberReference member)
            where T : class, Internal.IMemberInfo
        {
            var typeInformation = GetTypeInformation(member.DeclaringType);
            var identifier      = MemberIdentifier.New(this, member);

            IMemberInfo result;

            if (!typeInformation.Members.TryGetValue(identifier, out result))
            {
                // Console.Error.WriteLine("Warning: member not defined: {0}", member.FullName);
                return(null);
            }

            return((T)result);
        }
Beispiel #18
0
        // Show attribute information.
        private static void ShowMemberInformation(Member member)
        {
            Console.WriteLine("Member Name:{0} Code: {1}", member.MemberId.Name, member.MemberId.Code);
            foreach (MDSTestService.Attribute anAttribute in member.Attributes)
            {
                string attributeType = string.Empty;
                switch (anAttribute.Type)
                {
                case AttributeValueType.String:
                    attributeType = "String";
                    break;

                case AttributeValueType.Number:
                    attributeType = "Number";
                    break;

                case AttributeValueType.DateTime:
                    attributeType = "DateTime";
                    break;

                case AttributeValueType.Domain:
                    attributeType = "Domain";
                    break;

                case AttributeValueType.File:
                    attributeType = "File";
                    break;

                default:
                    attributeType = "Not Specified";
                    break;
                }

                // Get the code value when the attribute is DBA.
                if (anAttribute.Type == AttributeValueType.Domain)
                {
                    MemberIdentifier dbaMemberId = (MemberIdentifier)anAttribute.Value;
                    Console.WriteLine("Attribute Name:{0} Attribute Type: {1} Attribute Value:{2}", anAttribute.Identifier.Name, attributeType, dbaMemberId.Code);
                }
                else
                {
                    Console.WriteLine("Attribute Name:{0} Attribute Type: {1} Attribute Value:{2}", anAttribute.Identifier.Name, attributeType, anAttribute.Value);
                }
            }
        }
Beispiel #19
0
        /// <inheritdoc />
        public override IEnumerable <Value> WriteStringIndex(StringValue indexed, MemberIdentifier index, MemoryEntry writtenValue)
        {
            HashSet <Value>       result    = new HashSet <Value>();
            SimpleStringConverter converter = new SimpleStringConverter(Context);
            bool isConcrete = false;

            foreach (var value in converter.Evaluate(writtenValue.PossibleValues, out isConcrete))
            {
                string WrittenChar = value.Value;

                foreach (var number in ResolveStringIndex(indexed, index))
                {
                    Value newValue;
                    if (number < 0)
                    {
                        newValue = indexed;
                        SetWarning("Cannot index string with negative numbers", AnalysisWarningCause.INDEX_OUT_OF_RANGE);
                    }
                    else if (number < indexed.Value.Count())
                    {
                        StringBuilder newString = new StringBuilder();
                        newString.Append(indexed.Value);
                        newString[number] = WrittenChar[0];
                        newValue          = FlagsHandler.CopyFlags(indexed, Context.CreateString(newString.ToString()));
                    }
                    else if (number == indexed.Value.Count())
                    {
                        newValue = FlagsHandler.CopyFlags(indexed, Context.CreateString(indexed.Value + "" + WrittenChar[0].ToString()));
                    }
                    else
                    {
                        newValue = FlagsHandler.CopyFlags(indexed, Context.CreateString(indexed.Value + " " + WrittenChar[0].ToString()));
                    }
                    result.Add(newValue);
                }
            }
            if (!isConcrete)
            {
                result.Add(FlagsHandler.CopyFlags(indexed, Context.AnyStringValue));
            }
            return(result);
        }
        // Get the entity member identifier with specified model name, version name, entity name, member type, and entity member name.
        public static Collection <Member> GetEntityMembers(string modelName, string versionName, string entityName, MemberType memberType, string enchancedFilter = null)
        {
            MemberIdentifier memberIdentifier = new MemberIdentifier();

            // Create the request object to get the entity information.
            EntityMembersGetRequest getRequest = new EntityMembersGetRequest();

            getRequest.MembersGetCriteria = new EntityMembersGetCriteria();

            // Set the modelId, versionId, entityId, and the member name.
            getRequest.MembersGetCriteria.ModelId = new Identifier {
                Name = modelName
            };
            getRequest.MembersGetCriteria.VersionId = new Identifier {
                Name = versionName
            };
            getRequest.MembersGetCriteria.EntityId = new Identifier {
                Name = entityName
            };
            getRequest.MembersGetCriteria.MemberType         = memberType;
            getRequest.MembersGetCriteria.MemberReturnOption = MemberReturnOption.Data;

            if (!string.IsNullOrWhiteSpace(enchancedFilter))
            {
                if (!string.IsNullOrWhiteSpace(getRequest.MembersGetCriteria.SearchTerm))
                {
                    getRequest.MembersGetCriteria.SearchTerm = $"{getRequest.MembersGetCriteria.SearchTerm} AND {enchancedFilter}";
                }
                else
                {
                    getRequest.MembersGetCriteria.SearchTerm = $"{enchancedFilter}";
                }
            }

            // Get the entity member information
            EntityMembersGetResponse getResponse = ServiceReferencesSettings.clientProxy.EntityMembersGet(getRequest);

            ServiceReferencesSettings.HandleOperationErrors(getResponse.OperationResult);

            return(getResponse.EntityMembers.Members);
        }
Beispiel #21
0
        /// <summary>
        /// Returns identifiers of all indexes of arrays which was found in memory entry.
        /// </summary>
        /// <param name="snapshot">The snapshot.</param>
        /// <returns>Identifiers of all indexes of arrays which was found in memory entry</returns>
        public IEnumerable <MemberIdentifier> CollectIndexes(Snapshot snapshot)
        {
            HashSet <MemberIdentifier> indexes = new HashSet <MemberIdentifier>();

            foreach (AssociativeArray arrayValue in Arrays)
            {
                IArrayDescriptor descriptor;
                try {
                    descriptor = snapshot.Structure.Readonly.GetDescriptor(arrayValue);
                } catch (Exception) {
                    continue;
                }
                foreach (var index in descriptor.Indexes)
                {
                    indexes.Add(new MemberIdentifier(index.Key));
                }
            }

            indexes.Add(MemberIdentifier.getUnknownMemberIdentifier());
            return(indexes);
        }
Beispiel #22
0
        private List <MemberIdentifier> MakeUpMethodCallTree()
        {
            List <MemberIdentifier> callTree = new List <MemberIdentifier>();
            StackTrace st = new StackTrace();

            for (int i = 4; i < st.FrameCount; i++)  //Стартовое i зависит от количества вызовов для обработки
            {
                StackFrame       sf           = st.GetFrame(i);
                MemberIdentifier callerMember = new MemberIdentifier();
                callerMember.methodName = sf.GetMethod().Name;
                callerMember.className  = sf.GetMethod().DeclaringType.Name;
                if (callerMember.className == "ThreadHelper")  //Используется имя класса
                {
                    break;
                }

                callTree.Add(callerMember);
            }

            return(callTree);
        }
Beispiel #23
0
        private void initTaintedArray(string name)
        {
            // Get the variable
            var varName = new VariableName(name);

            EntryInput.FetchFromGlobal(varName);
            var variable = EntryInput.GetVariable(new VariableIdentifier(varName), true);

            // Create array and write it into the variable
            var array = EntryInput.CreateArray();

            array.SetInfo(new Flags(Flags.CreateDirtyFlags()));
            variable.WriteMemory(EntryInput.Snapshot, new MemoryEntry(array));

            // Create tainted any value
            var anyValue = EntryInput.AnyValue.SetInfo(new Flags(Flags.CreateDirtyFlags()));

            // Write tainted anyvalue to unknown field of the array (now stored in the variable)
            var entry = variable.ReadIndex(EntryInput.Snapshot, MemberIdentifier.getAnyMemberIdentifier());

            entry.WriteMemory(EntryInput.Snapshot, new MemoryEntry(anyValue));
        }
Beispiel #24
0
        /// <inheritdoc />
        public override IEnumerable <Value> ReadStringIndex(StringValue value, MemberIdentifier index)
        {
            HashSet <Value> result = new HashSet <Value>();

            foreach (var number in ResolveStringIndex(value, index))
            {
                if (number < 0)
                {
                    result.Add(value);
                    SetWarning("Cannot index string with negative numbers", AnalysisWarningCause.INDEX_OUT_OF_RANGE);
                }
                else if (number < value.Value.Count())
                {
                    result.Add(Context.CreateString(value.Value[number].ToString()));
                }
                else
                {
                    result.Add(Context.CreateString(""));
                }
            }
            return(result);
        }
Beispiel #25
0
        IMemberInfo ITypeInfoSource.Get(MemberReference member)
        {
            var typeInfo = GetTypeInformation(member.DeclaringType);

            if (typeInfo == null)
            {
                Console.Error.WriteLine("Warning: type not loaded: {0}", member.DeclaringType.FullName);
                return(null);
            }

            var identifier = MemberIdentifier.New(this, member);

            IMemberInfo result;

            if (!typeInfo.Members.TryGetValue(identifier, out result))
            {
                // Console.Error.WriteLine("Warning: member not defined: {0}", member.FullName);
                return(null);
            }

            return(result);
        }
Beispiel #26
0
        /// <inheritdoc />
        protected override void flowThrough()
        {
            if (Index == null)
            {
                // $a[] = value;
                // Creates new index that is biggest integer index in $a + 1 and writes the value to this index

                // TODO:
                // What is should do
                // Iterate through all arrays in UsedItem
                // for each array iterate through all indices and find the biggest integer index
                // for each array resolve the index
                // LValue should represent all these indices

                // What it does
                // Iterate through all indices of all arrays in UsedItem and find the biggest integer index
                // Resolve this index in all arrays

                // TODO: causes non-termination: while() $a[] = 1;
                // Do this only for non-widened arrays. Then write to unknown index
                // Now arrays are not widened => we use just unknown index

                /*
                 * IndexIdentifier = new MemberIdentifier (System.Convert.ToString(
                 *  UsedItem.Value.BiggestIntegerIndex(OutSnapshot, Services.Evaluator) + 1,
                 *  CultureInfo.InvariantCulture));
                 */

                // use the unknown index
                IndexIdentifier = MemberIdentifier.getUnknownMemberIdentifier();
            }
            else
            {
                IndexIdentifier = Services.Evaluator.MemberIdentifier(Index.Value.ReadMemory(OutSnapshot));
            }
            LValue = Services.Evaluator.ResolveIndex(UsedItem.Value, IndexIdentifier);
        }
Beispiel #27
0
        public static TypeReference SubstituteTypeArgs(ITypeInfoSource typeInfo, TypeReference type, MemberReference member)
        {
            var gp = (type as GenericParameter);

            if (gp != null)
            {
                if (gp.Owner.GenericParameterType == GenericParameterType.Method)
                {
                    var ownerIdentifier  = new MemberIdentifier(typeInfo, gp.Owner as MethodReference);
                    var memberIdentifier = new MemberIdentifier(typeInfo, member as dynamic);

                    if (!ownerIdentifier.Equals(memberIdentifier, typeInfo))
                    {
                        return(type);
                    }

                    if (!(member is GenericInstanceMethod))
                    {
                        return(type);
                    }
                }
                else
                {
                    var declaringType   = member.DeclaringType;
                    var ownerIdentifier = new TypeIdentifier(gp.Owner as TypeReference);
                    var typeIdentifier  = new TypeIdentifier(declaringType);

                    if (!ownerIdentifier.Equals(typeIdentifier))
                    {
                        return(type);
                    }
                }
            }

            return(TypeAnalysis.SubstituteTypeArgs(type, member));
        }
Beispiel #28
0
        // Get the entity member identifier with specified model name, version name, entity name, member type, and entity member code.
        private static MemberIdentifier GetEntityMemberByCode(string modelName, string versionName, string entityName, MemberType memberType, string memberCode)
        {
            MemberIdentifier memberIdentifier = new MemberIdentifier();

            // Create the request object to get the entity information.
            EntityMembersGetRequest getRequest = new EntityMembersGetRequest();

            getRequest.MembersGetCriteria = new EntityMembersGetCriteria();

            // Set the modelId, versionId, entityId, and the member code.
            getRequest.MembersGetCriteria.ModelId = new Identifier {
                Name = modelName
            };
            getRequest.MembersGetCriteria.VersionId = new Identifier {
                Name = versionName
            };
            getRequest.MembersGetCriteria.EntityId = new Identifier {
                Name = entityName
            };
            getRequest.MembersGetCriteria.MemberType         = memberType;
            getRequest.MembersGetCriteria.MemberReturnOption = MemberReturnOption.Data;
            getRequest.MembersGetCriteria.SearchTerm         = "Code = '" + memberCode + "'";

            // Get the entity member information
            EntityMembersGetResponse getResponse = clientProxy.EntityMembersGet(getRequest);

            // Get the entity member identifier.
            memberIdentifier = getResponse.EntityMembers.Members[0].MemberId;

            // Show attribute information.
            ShowMemberInformation(getResponse.EntityMembers.Members[0]);

            HandleOperationErrors(getResponse.OperationResult);

            return(memberIdentifier);
        }
		public static MemberIdentifier GetIdentifier(string assemblyFilePath, IMemberDefinition member)
		{
			TypeDefinition td = member as TypeDefinition;
			if (td == null)
			{
				td = member.DeclaringType;
			}

			MemberIdentifier result = new MemberIdentifier(new AssemblyIdentifier(assemblyFilePath), new UniqueMemberIdentifier(td.Module.FilePath, member.MetadataToken.ToInt32()));
			return result;
		}
Beispiel #30
0
 internal VariableIndexKey(VariableKeyBase indexedVariable, MemberIdentifier index)
     : base(indexedVariable)
 {
     _index = index;
 }
Beispiel #31
0
        public void EmitMain()
        {
            var typeId = new TypeIdentifier(Assembly.EntryPoint.DeclaringType);
            var memberId = new MemberIdentifier(Translator.TypeInfoProvider, Assembly.EntryPoint);
            var entryPointIdentifier = new QualifiedMemberIdentifier(typeId, memberId);

            var mainExpression = Translator.FunctionCache.GetExpression(entryPointIdentifier);

            var astEmitter = (AstEmitter)EntryPointAstEmitter;
            var mainEmitter = new AstEmitter(this, Formatter, astEmitter.JSIL, astEmitter.TypeSystem, astEmitter.TypeInfo, astEmitter.Configuration, isTopLevel: true);

            Switch(PrecedingType.TopLevel);

            if (NeedStaticInit) {
                Formatter.ConditionalNewLine();
                Formatter.WriteRaw("(invoke \"__static_init\")");
                Formatter.NewLine();
                Formatter.NewLine();
            }

            var body = mainExpression.Body;
            foreach (var stmt in body.Statements) {
                mainEmitter.Visit(stmt);
                Formatter.ConditionalNewLine();
            }
        }
Beispiel #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnyStringValueLocation"/> class.
 /// </summary>
 /// <param name="containingIndex">Index of the containing.</param>
 /// <param name="index">The index.</param>
 /// <param name="value">The value.</param>
 public AnyStringValueLocation(MemoryIndex containingIndex, MemberIdentifier index, AnyStringValue value)
 {
     this.containingIndex = containingIndex;
     this.index           = index;
     this.value           = value;
 }
        // Get the entity member identifier with specified model name, version name, entity name, member type, and entity member name.
        private static MemberIdentifier GetEntityMemberByName(string modelName, string versionName, string entityName, MemberType memberType, string memberName)
        {
            MemberIdentifier memberIdentifier = new MemberIdentifier();

            // Create the request object to get the entity information.
            EntityMembersGetRequest getRequest = new EntityMembersGetRequest();
            getRequest.MembersGetCriteria = new EntityMembersGetCriteria();

            // Set the modelId, versionId, entityId, and the member name.
            getRequest.MembersGetCriteria.ModelId = new Identifier { Name = modelName };
            getRequest.MembersGetCriteria.VersionId = new Identifier { Name = versionName };
            getRequest.MembersGetCriteria.EntityId = new Identifier { Name = entityName };
            getRequest.MembersGetCriteria.MemberType = memberType;
            getRequest.MembersGetCriteria.MemberReturnOption = MemberReturnOption.Data;
            getRequest.MembersGetCriteria.SearchTerm = "Name = '" + memberName + "'";

            // Get the entity member information
            EntityMembersGetResponse getResponse = clientProxy.EntityMembersGet(getRequest);

            // Get the entity member identifier.
            memberIdentifier = getResponse.EntityMembers.Members[0].MemberId;

            // Show attribute information.
            ShowMemberInformation(getResponse.EntityMembers.Members[0]);

            HandleOperationErrors(getResponse.OperationResult);

            return memberIdentifier;
        }