code: func newResourceDiff(schema map[string]*Schema, config *terraform.ResourceConfig, state *terraform.InstanceState, diff *terraform.InstanceDiff) *ResourceDiff {
  	d := &ResourceDiff{
  		config: config,
  		state:  state,
  		diff:   diff,
  		schema: schema,
  	}
  
  	d.newWriter = &newValueWriter{
  		MapFieldWriter: &MapFieldWriter{Schema: d.schema},
  	}
  	readers := make(map[string]FieldReader)
  	var stateAttributes map[string]string
  	if d.state != nil {
  		stateAttributes = d.state.Attributes
  		readers["state"] = &MapFieldReader{
  			Schema: d.schema,
  			Map:    BasicMapReader(stateAttributes),
  		}
  	}
  	if d.config != nil {
  		readers["config"] = &ConfigFieldReader{
  			Schema: d.schema,
  			Config: d.config,
  		}
  	}
  	if d.diff != nil {
  		readers["diff"] = &DiffFieldReader{
  			Schema: d.schema,
  			Diff:   d.diff,
  			Source: &MultiLevelFieldReader{
  				Levels:  []string{"state", "config"},
  				Readers: readers,
  			},
  		}
  	}
  	readers["newDiff"] = &newValueReader{
  		MapFieldReader: &MapFieldReader{
  			Schema: d.schema,
  			Map:    BasicMapReader(d.newWriter.Map()),
  		},
  		computedKeys: d.newWriter.ComputedKeysMap(),
  	}
  	d.multiReader = &MultiLevelFieldReader{
  		Levels: []string{
  			"state",
  			"config",
  			"diff",
  			"newDiff",
  		},
  
  		Readers: readers,
  	}
  
  	d.updatedKeys = make(map[string]bool)
  	d.forcedNewKeys = make(map[string]bool)
  
  	return d
  }
docs: // newResourceDiff creates a new ResourceDiff instance.