コード例 #1
0
 public static StackFrame ToStackFrame(this ISourcePositionInfo location, string name = null) =>
 new StackFrame
 {
     Id     = _generator.Next(),
     Column = location.LinePosition,
     Line   = location.LineNumber,
     Name   = name,
     Source = location.Source
 };
コード例 #2
0
        public ConstantExpression(object value, TypeSpecifier type, ISourcePositionInfo location = null) : base(type, location)
        {
            if (value == null)
            {
                Error.ArgumentNull("value");
            }

            Value = value;
        }
コード例 #3
0
        public ConstantExpression(object value, ISourcePositionInfo location = null) : base(TypeSpecifier.Any, location)
        {
            if (value == null)
            {
                Error.ArgumentNull("value");
            }

            if (Any.TryConvertToSystemValue(value, out var systemValue))
            {
                Value = systemValue;
            }
            else
            {
                throw Error.InvalidOperation("Internal logic error: encountered unmappable Value of type " + Value.GetType().Name);
            }

            if (Value is bool)
            {
                ExpressionType = TypeSpecifier.Boolean;
            }
            else if (Value is string)
            {
                ExpressionType = TypeSpecifier.String;
            }
            else if (Value is Int64)
            {
                ExpressionType = TypeSpecifier.Integer;
            }
            else if (Value is decimal)
            {
                ExpressionType = TypeSpecifier.Decimal;
            }
            else if (Value is PartialDateTime)
            {
                ExpressionType = TypeSpecifier.DateTime;
            }
            else if (Value is PartialTime)
            {
                ExpressionType = TypeSpecifier.Time;
            }
            else if (Value is PartialDate)
            {
                ExpressionType = TypeSpecifier.Date;
            }
            else if (Value is Quantity)
            {
                ExpressionType = TypeSpecifier.Quantity;
            }
            else
            {
                throw Error.InvalidOperation($"Internal logic error: encountered unmappable Value of type " + Value.GetType().Name);
            }
        }
コード例 #4
0
        public ConstantExpression(object value, TypeSpecifier type, ISourcePositionInfo location = null) : base(type, location)
        {
            if (value == null)
            {
                Error.ArgumentNull("value");
            }
            if (value is P.Any && (value is P.Boolean || value is P.Decimal || value is P.Integer || value is P.Long || value is P.String))
            {
                throw new ArgumentException("Internal error: not yet ready to handle Any-based primitives in FhirPath.");
            }

            Value = value;
        }
コード例 #5
0
        public static string GetLocationLabel(this ISourcePositionInfo loc)
        {
            if (loc == null)
            {
                throw new ArgumentNullException(nameof(loc));
            }

            var result = $"line {loc.LineNumber}";

            if (loc.LinePosition > 0)
            {
                result += $", column {loc.LinePosition}";
            }
            return(result);
        }
コード例 #6
0
        public ConstantExpression(object value, ISourcePositionInfo location = null) : base(TypeSpecifier.Any, location)
        {
            if (value == null)
            {
                Error.ArgumentNull("value");
            }

            if (Any.TryConvertToSystemValue(value, out var systemValue))
            {
                Value          = systemValue;
                ExpressionType = TypeSpecifier.ForNativeType(value.GetType());
            }
            else
            {
                throw Error.InvalidOperation("Internal logic error: encountered unmappable Value of type " + Value.GetType().Name);
            }
        }
コード例 #7
0
        public ConstantExpression(object value, ISourcePositionInfo location = null) : base(TypeInfo.Any, location)
        {
            if (value == null)
            {
                Error.ArgumentNull("value");
            }

            Value = Primitives.ConvertToPrimitiveValue(value);

            if (Value is bool)
            {
                ExpressionType = TypeInfo.Boolean;
            }
            else if (Value is string)
            {
                ExpressionType = TypeInfo.String;
            }
            else if (Value is Int64)
            {
                ExpressionType = TypeInfo.Integer;
            }
            else if (Value is Decimal)
            {
                ExpressionType = TypeInfo.Decimal;
            }
            else if (Value is PartialDateTime)
            {
                ExpressionType = TypeInfo.DateTime;
            }
            else if (Value is PartialTime)
            {
                ExpressionType = TypeInfo.Time;
            }
            else
            {
                throw Error.InvalidOperation("Internal logic error: encountered unmappable Value of type " + Value.GetType().Name);
            }
        }
コード例 #8
0
 public VariableRefExpression(string name, ISourcePositionInfo location = null) : base(TypeSpecifier.Any, location)
 {
     Name = name ?? throw Error.ArgumentNull("name");
 }
コード例 #9
0
 protected Expression(TypeSpecifier type, ISourcePositionInfo location) : this(type)
 {
     Location = location;
 }
コード例 #10
0
 public FunctionCallExpression(Expression focus, string name, TypeSpecifier type, IEnumerable <Expression> arguments, ISourcePositionInfo location = null) : base(type, location)
 {
     if (string.IsNullOrEmpty(name))
     {
         throw Error.ArgumentNull("name");
     }
     Focus        = focus;
     FunctionName = name;
     Arguments    = arguments ?? throw Error.ArgumentNull("arguments");
 }