Пример #1
0
        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);
        }
Пример #2
0
        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));
        }