Sha256: 94417aa8924e2a93c2cd8515d86a28cf83648dee4a8afc6f636c133b98de6829
Contents?: true
Size: 1007 Bytes
Versions: 5
Compression:
Stored size: 1007 Bytes
Contents
# frozen_string_literal: true module Grumlin module Translator class << self def to_bytecode(steps) return arg_to_bytecode(steps) if steps.is_a?(AnonymousStep) steps.map do |step| arg_to_bytecode(step) end end def to_bytecode_query(steps) steps.map do |step| arg_to_query_bytecode(step) end end private def arg_to_bytecode(arg) return arg unless arg.is_a?(AnonymousStep) args = arg.args.flatten.map do |a| a.instance_of?(AnonymousStep) ? to_bytecode(a.steps) : arg_to_bytecode(a) end [arg.name, *args] end def arg_to_query_bytecode(arg) return ["none"] if arg.nil? return arg unless arg.is_a?(AnonymousStep) args = arg.args.flatten.map do |a| a.instance_of?(AnonymousStep) ? Typing.to_bytecode(to_bytecode(a.steps)) : arg_to_query_bytecode(a) end [arg.name, *args] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems