Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.FieldReference


                }

                final FieldDefinition switchMapField;

                try {
                    final FieldReference r = new MetadataParser(currentType.getResolver()).parseField(
                        currentType,
                        switchMapMethod.getName(),
                        switchMapMethod.getReturnType().getErasedSignature()
                    );

                    switchMapField = r.resolve();
                }
                catch (Throwable t) {
                    return super.visitSwitchStatement(node, data);
                }
View Full Code Here


            return super.visitSwitchStatement(node, data);
        }

        @Override
        public Void visitFieldDeclaration(final FieldDeclaration node, final Void data) {
            final FieldReference field = (FieldReference) node.getUserData(Keys.MEMBER_REFERENCE);

            if (isSwitchMapField(field)) {
                final String key = makeKey(field);

                SwitchMapInfo info = _switchMaps.get(key);
View Full Code Here

            if (isSwitchMapMethod(methodDefinition)) {
                final Match m = SWITCH_TABLE_METHOD_BODY.match(node.getBody());

                if (m.success()) {
                    final MemberReferenceExpression fieldAccess = first(m.<MemberReferenceExpression>get("fieldAccess"));
                    final FieldReference field = (FieldReference) fieldAccess.getUserData(Keys.MEMBER_REFERENCE);
                    final List<MemberReferenceExpression> enumValues = toList(m.<MemberReferenceExpression>get("enumValue"));
                    final List<PrimitiveExpression> tableValues = toList(m.<PrimitiveExpression>get("tableValue"));

                    assert field != null &&
                           tableValues.size() == enumValues.size();
View Full Code Here

        if (_operand instanceof FieldReference) {
            if (!(e._operand instanceof FieldReference)) {
                return false;
            }

            final FieldReference f1 = (FieldReference) _operand;
            final FieldReference f2 = (FieldReference) e._operand;

            if (!StringUtilities.equals(f1.getFullName(), f2.getFullName())) {
                return false;
            }
        }
        else if (_operand instanceof MethodReference) {
            if (!(e._operand instanceof MethodReference)) {
                return false;
            }

            final MethodReference f1 = (MethodReference) _operand;
            final MethodReference f2 = (MethodReference) e._operand;

            if (!StringUtilities.equals(f1.getFullName(), f2.getFullName()) ||
                !StringUtilities.equals(f1.getErasedSignature(), f2.getErasedSignature())) {

                return false;
            }
        }
        else if (!Comparer.equals(e._operand, _operand)) {
View Full Code Here

            }
        }

        for (final AstNode candidate : _removeQualifierCandidates) {
            if (candidate instanceof MemberReferenceExpression) {
                final FieldReference field = (FieldReference) candidate.getUserData(Keys.MEMBER_REFERENCE);

                if (field != null) {
                    final IdentifierExpression identifier = new IdentifierExpression(((Expression) candidate).getOffset(), field.getName());
                    identifier.copyUserDataFrom(candidate);
                    candidate.replaceWith(identifier);
                }
            }
        }
View Full Code Here

        else {
            parser = new MetadataParser(IMetadataResolver.EMPTY);
        }

        final TypeReference declaringType = parser.parseTypeDescriptor("java/lang/" + jvmType.name());
        final FieldReference field = parser.parseField(declaringType, fieldName, jvmType.getDescriptorPrefix());

        if (currentType != null &&
            node.getParent() instanceof VariableInitializer &&
            node.getParent().getParent() instanceof FieldDeclaration &&
            StringUtilities.equals(currentType.getInternalName(), declaringType.getInternalName())) {
View Full Code Here

        final Match match = FIELD_ASSIGNMENT.match(node);

        if (match.success()) {
            final Expression target = (Expression) firstOrDefault(match.get("target"));
            final FieldReference reference = (FieldReference) target.getUserData(Keys.MEMBER_REFERENCE);
            final FieldDefinition definition = reference.resolve();

            //
            // Final fields with constant values area already initialized inline, so any additional assignments
            // are illegal; remove them.
            //
            if (definition != null && definition.isFinal() && definition.getConstantValue() != null) {
                node.remove();
                return null;
            }

            if (_currentInitializerMethod != null &&
                StringUtilities.equals(context.getCurrentType().getInternalName(), reference.getDeclaringType().getInternalName())) {

                _initializers.put(reference.getFullName(), node);
            }
        }

        return null;
    }
View Full Code Here

                }

                final FieldDefinition switchMapField;

                try {
                    final FieldReference r = new MetadataParser(currentType.getResolver()).parseField(
                        currentType,
                        switchMapMethod.getName(),
                        switchMapMethod.getReturnType().getErasedSignature()
                    );

                    switchMapField = r.resolve();
                }
                catch (Throwable t) {
                    return super.visitSwitchStatement(node, data);
                }
View Full Code Here

            return super.visitSwitchStatement(node, data);
        }

        @Override
        public Void visitFieldDeclaration(final FieldDeclaration node, final Void data) {
            final FieldReference field = (FieldReference) node.getUserData(Keys.MEMBER_REFERENCE);

            if (isSwitchMapField(field)) {
                final String key = makeKey(field);

                SwitchMapInfo info = _switchMaps.get(key);
View Full Code Here

            if (isSwitchMapMethod(methodDefinition)) {
                final Match m = SWITCH_TABLE_METHOD_BODY.match(node.getBody());

                if (m.success()) {
                    final MemberReferenceExpression fieldAccess = first(m.<MemberReferenceExpression>get("fieldAccess"));
                    final FieldReference field = (FieldReference) fieldAccess.getUserData(Keys.MEMBER_REFERENCE);
                    final List<MemberReferenceExpression> enumValues = toList(m.<MemberReferenceExpression>get("enumValue"));
                    final List<PrimitiveExpression> tableValues = toList(m.<PrimitiveExpression>get("tableValue"));

                    assert field != null &&
                           tableValues.size() == enumValues.size();
View Full Code Here

TOP

Related Classes of com.strobel.assembler.metadata.FieldReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.