public bool Resolve(IVariableStore variables, VariableValueSource source, out VariableValue result) { if (source.Type == VariableSourceType.Reference) { return(Resolve(variables, source.Reference, out result)); } result = source.Value; return(true); }
private VariableRefEvaluator GetVariableRefEvaluator(InputValueDef inputDef, TypeRef resultTypeRef, VariableValueSource varRef) { var varDecl = _currentOp.Variables.FirstOrDefault(vd => vd.Name == varRef.VariableName); if (varDecl == null) { throw new InvalidInputException($"Variable ${varRef.VariableName} not defined.", varRef); } // check type compatibility if (!resultTypeRef.IsConvertibleFrom(varDecl.InputDef.TypeRef)) { throw new InvalidInputException( $"Incompatible types: variable ${varRef.VariableName} cannot be converted to type '{resultTypeRef.Name}'", varRef); } return(new VariableRefEvaluator(inputDef, varDecl)); }