public MemberReference memberReference(AddressValue structureOrUnionReference, Field field) { ObjectType memberType = field.getType(); PointerType memberReferenceType = typeFactory.pointerType(memberType); return (MemberReference) canonic(new CommonMemberReference(memberReferenceType, structureOrUnionReference, field)); }
private Value evaluateMemberAccess(Value structureOrUnionValue, Field field) throws UnsourcedException { if (structureOrUnionValue instanceof StructureValue) { return ((StructureValue) structureOrUnionValue).getMember(field); } if (structureOrUnionValue instanceof UnionValue) { UnionValue unionValue = (UnionValue) structureOrUnionValue; Field unionField = unionValue.getField(); if (!unionField.equals(field)) throw new UnsourcedException( "Union value field differs from requested field:\n" + unionField + "\n" + field); return unionValue.getMemberValue(); } // TODO: need to create a new dot value. throw new UnsourcedException( "Cannot evaluate structure or union value: " + structureOrUnionValue); }