Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | 78x 1x 1x 76x 19x 1x 16x 16x 16x 4x 4x 1x 16x 16x 16x 4x 4x 1x 36x 36x 36x 6x 6x 1x 16x 4x 1x 16x 4x 1x 16x 16x 16x 4x 4x 1x 25x 5x 3x 1x 81x 81x 81x 81x 9x 9x 9x 1x 40x 8x 1x 40x 8x | I{ Expression, UnimplementedExpression } = require './expression'
{ build } = require './builder'
module.exports.Concatenate = class Concatenate extends Expression
constructor: (json) ->
super
exec: (ctx) ->
args = @execArgs(ctx)
if (args.some (x) -> not x?) then null else args.reduce (x,y) -> x + y
module.exports.Combine = class Combine extends Expression
constructor: (json) ->
super
@source = build json.source
@separator = build json.separator
exec: (ctx) ->
source = @source.execute(ctx)
separator = if @separator? then @separator.execute(ctx) else ''
if (not source? or source.some (x) -> not x?) then null else source.join(separator)
module.exports.Split = class Split extends Expression
constructor: (json) ->
super
@stringToSplit = build json.stringToSplit
@separator = build json.separator
exec: (ctx) ->
stringToSplit = @stringToSplit.execute(ctx)
separator = @separator.execute(ctx)
if not (stringToSplit? and separator?) then null else stringToSplit.split(separator)
module.exports.SplitOnMatches = class SplitOnMatches extends Expression
constructor: (json) ->
super
@stringToSplit = build json.stringToSplit
@separatorPattern = build json.separatorPattern
exec: (ctx) ->
stringToSplit = @stringToSplit.execute(ctx)
separatorPattern = @separatorPattern.execute(ctx)
if not (stringToSplit? and separatorPattern?) then null else stringToSplit.split(new RegExp(separatorPattern))
# Length is completely handled by overloaded#Length
module.exports.Upper = class Upper extends Expression
constructor: (json) ->
super
exec: (ctx) ->
arg = @execArgs ctx
if arg? then arg.toUpperCase() else null
module.exports.Lower = class Lower extends Expression
constructor: (json) ->
super
exec: (ctx) ->
arg = @execArgs ctx
if arg? then arg.toLowerCase() else null
# Indexer is completely handled by overloaded#Indexer
module.exports.PositionOf = class PositionOf extends Expression
constructor: (json) ->
super
@pattern = build json.pattern
@string = build json.string
exec: (ctx) ->
pattern = @pattern.execute(ctx)
string = @string.execute(ctx)
if not (pattern? and string?) then null else string.indexOf(pattern)
module.exports.Matches = class Matches extends Expression
constructor: (json) ->
super
exec: (ctx) ->
[string, pattern] = @execArgs ctx
return null if not (string? and pattern?)
if string.match(new RegExp(pattern)) then true else false
module.exports.Substring = class Substring extends Expression
constructor: (json) ->
super
@stringToSub = build json.stringToSub
@startIndex = build json.startIndex
@length = build json['length']
exec: (ctx) ->
stringToSub = @stringToSub.execute(ctx)
startIndex = @startIndex.execute(ctx)
length = if @length? then @length.execute(ctx) else null
# According to spec: If stringToSub or startIndex is null, or startIndex is out of range, the result is null.
if not stringToSub? || not startIndex? || startIndex < 0 || startIndex >= stringToSub.length
null
else if length?
stringToSub.substr(startIndex, length)
else
stringToSub.substr(startIndex)
module.exports.StartsWith = class StartsWith extends Expression
constructor: (json) ->
super
exec: (ctx) ->
args = @execArgs ctx
if (args.some (x) -> not x?) then null else args[0].slice(0, args[1].length) == args[1]
module.exports.EndsWith = class EndsWith extends Expression
constructor: (json) ->
super
exec: (ctx) ->
args = @execArgs ctx
if (args.some (x) -> not x?) then null else args[1] is '' or args[0].slice(-args[1].length) == args[1] |