Ejemplo n.º 1
0
        protected override Entity InternalResolve <TNode>(
            GraphStructuredProgram <TNode> program,
            ResolvedMethod <TNode> method,
            Reference reference)
        {
            var real = (ClassReference)reference;

            return(program.GetOrCreateClass(real.ClassId).Id);
        }
        protected override Entity InternalResolve <TNode>(
            GraphStructuredProgram <TNode> program,
            ResolvedMethod <TNode> method,
            Reference reference)
        {
            var real   = (LocalVariableReference)reference;
            var exists = method.Variables.TryGetValue(real.Index, out var resolved);

            Trace.Assert(exists);
            if (!exists)
            {
                method.AddLocalVariable(new ResolvedLocalVariable(real.Index));
                resolved = method.Variables[real.Index];
            }

            if (resolved.DefaultClassType < 0 && real.DefaultType != null)
            {
                var defaultType = program.GetOrCreateClass(real.DefaultType);
                resolved.DefaultClassType = defaultType.Id.GlobalId;
            }

            return(resolved);
        }
Ejemplo n.º 3
0
        protected override Entity InternalResolve <TNode>(
            GraphStructuredProgram <TNode> program,
            ResolvedMethod <TNode> method,
            Reference reference)
        {
            var classFieldReference = (ClassFieldReference)reference;

            if (classFieldReference.Owner is ClassReference classReference)
            {
                var clazz = program.GetOrCreateClass(classReference.ClassId);
                var field = program.GetOrCreateClassField(clazz.Id, classFieldReference.Name);

                if (classFieldReference.DefaultClassType != null)
                {
                    field.DefaultClassType = program.GetOrCreateClass(classFieldReference.DefaultClassType).Id.GlobalId;
                }

                return(field);
            }
            else if (classFieldReference.Owner is LocalVariableReference localVariableReference)
            {
                var localVariable = method.Variables[localVariableReference.Index];
                var fieldId       = program.GetOrCreateFieldId(classFieldReference.Name);

                var resolvedObjectField = new ResolvedObjectField(localVariable, fieldId)
                {
                    FindClassField = program.FindClassFieldById
                };

                method.StoreAdditionalVariable(resolvedObjectField);
                return(resolvedObjectField);
            }
            else if (classFieldReference.Owner is ClassFieldReference anotherReference)
            {
                var resolvedAnotherReference = (SecondaryEntity)Resolve(program, method, anotherReference);
                var fieldId = program.GetOrCreateFieldId(classFieldReference.Name);

                var resolvedObjectField = new ResolvedObjectField(resolvedAnotherReference, fieldId)
                {
                    FindClassField = program.FindClassFieldById
                };

                method.StoreAdditionalVariable(resolvedObjectField);
                return(resolvedObjectField);
            }
            else if (classFieldReference.Owner is ClassPropertyReference propertyReference)
            {
                var resolvedAnotherReference = (SecondaryEntity)Resolve(program, method, propertyReference);
                var fieldId = program.GetOrCreateFieldId(classFieldReference.Name);

                var resolvedObjectField = new ResolvedObjectField(resolvedAnotherReference, fieldId)
                {
                    FindClassField = program.FindClassFieldById
                };

                method.StoreAdditionalVariable(resolvedObjectField);
                return(resolvedObjectField);
            }

            Trace.Assert(false);
            return(null);
        }