[Groonga-commit] groonga/groonga at a4b4126 [master] expr optimize: add support for getting member

Back to archive index
Kouhei Sutou null+****@clear*****
Mon Mar 4 12:34:41 JST 2019


Kouhei Sutou	2019-03-04 12:34:41 +0900 (Mon, 04 Mar 2019)

  Revision: a4b412670babf19ea11adcab1cfcdd755ce7fe91
  https://github.com/groonga/groonga/commit/a4b412670babf19ea11adcab1cfcdd755ce7fe91

  Message:
    expr optimize: add support for getting member

  Added files:
    lib/mrb/scripts/expression_tree/member.rb
  Modified files:
    lib/mrb/scripts/expression_tree.rb
    lib/mrb/scripts/expression_tree/sources.am
    lib/mrb/scripts/expression_tree_builder.rb

  Modified: lib/mrb/scripts/expression_tree.rb (+1 -0)
===================================================================
--- lib/mrb/scripts/expression_tree.rb    2019-03-04 12:30:21 +0900 (f27a4457e)
+++ lib/mrb/scripts/expression_tree.rb    2019-03-04 12:34:41 +0900 (fbb4898ff)
@@ -5,6 +5,7 @@ require "expression_tree/constant"
 require "expression_tree/function_call"
 require "expression_tree/index_column"
 require "expression_tree/logical_operation"
+require "expression_tree/member"
 require "expression_tree/procedure"
 require "expression_tree/reference"
 require "expression_tree/table"

  Added: lib/mrb/scripts/expression_tree/member.rb (+18 -0) 100644
===================================================================
--- /dev/null
+++ lib/mrb/scripts/expression_tree/member.rb    2019-03-04 12:34:41 +0900 (15d432b18)
@@ -0,0 +1,18 @@
+module Groonga
+  module ExpressionTree
+    class Member
+      attr_reader :variable
+      attr_reader :index
+      def initialize(variable, index)
+        @variable = variable
+        @index = index
+      end
+
+      def build(expression)
+        @variable.build(expression)
+        @index.build(expression)
+        expression.append_operator(Operator::GET_MEMBER, 2)
+      end
+    end
+  end
+end

  Modified: lib/mrb/scripts/expression_tree/sources.am (+1 -0)
===================================================================
--- lib/mrb/scripts/expression_tree/sources.am    2019-03-04 12:30:21 +0900 (d5269d111)
+++ lib/mrb/scripts/expression_tree/sources.am    2019-03-04 12:34:41 +0900 (54a318634)
@@ -6,6 +6,7 @@ RUBY_SCRIPT_FILES =				\
 	function_call.rb			\
 	index_column.rb				\
 	logical_operation.rb			\
+	member.rb				\
 	procedure.rb				\
 	reference.rb				\
 	table.rb				\

  Modified: lib/mrb/scripts/expression_tree_builder.rb (+5 -0)
===================================================================
--- lib/mrb/scripts/expression_tree_builder.rb    2019-03-04 12:30:21 +0900 (f708d60c5)
+++ lib/mrb/scripts/expression_tree_builder.rb    2019-03-04 12:34:41 +0900 (5f9ecc326)
@@ -89,6 +89,11 @@ module Groonga
         when Operator::GET_VALUE
           node = ExpressionTree::Variable.new(code.value)
           stack.push(node)
+        when Operator::GET_MEMBER
+          index = stack.pop
+          variable = stack.pop
+          node = ExpressionTree::Member.new(variable, index)
+          stack.push(node)
         when Operator::ASSIGN
           value = stack.pop
           variable = stack.pop
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190304/2b30371d/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index