Esempio n. 1
0
def op_dot(context, receiver, expr, operator):
    executor = helpers.get_executor()
    type_context = executor.context_manager.create_type_context(receiver.type)
    obj_context = executor.context_manager.create_object_context(receiver)
    ctx2 = helpers.link_contexts(helpers.link_contexts(context, type_context),
                                 obj_context)
    return operator(ctx2, receiver, expr)
Esempio n. 2
0
def op_dot(context, receiver, expr, operator):
    executor = helpers.get_executor()
    type_context = executor.context_manager.create_type_context(receiver.type)
    obj_context = executor.context_manager.create_object_context(receiver)
    ctx2 = helpers.link_contexts(
        helpers.link_contexts(context, type_context),
        obj_context)
    return operator(ctx2, receiver, expr)
Esempio n. 3
0
 def create_package_context(self, package):
     context = super(ContextManager, self).create_package_context(
         package)
     if package.name == 'io.murano':
         context = helpers.link_contexts(
             context, yaql_functions.get_restricted_context())
     return context
Esempio n. 4
0
    def create_object_context(self, obj, caller_context=None):
        if isinstance(obj, dsl_types.MuranoClass):
            obj_type = obj
            obj = None
        else:
            obj_type = obj.type
        class_context = self.create_type_context(obj_type)
        if obj is not None:
            context = helpers.link_contexts(
                class_context, self.context_manager.create_object_context(
                    obj)).create_child_context()
            context[constants.CTX_THIS] = obj.real_this
            context['this'] = obj.real_this
            context[''] = obj.real_this
        else:
            context = class_context.create_child_context()
            type_ref = obj_type.get_reference()
            context[constants.CTX_THIS] = type_ref
            context['this'] = type_ref
            context[''] = type_ref

        if caller_context is not None:
            caller = caller_context
            while caller is not None and caller[constants.CTX_SKIP_FRAME]:
                caller = caller[constants.CTX_CALLER_CONTEXT]
            context[constants.CTX_NAMES_SCOPE] = caller_context[
                constants.CTX_NAMES_SCOPE]
            context[constants.CTX_CALLER_CONTEXT] = caller
            context[constants.CTX_ALLOW_PROPERTY_WRITES] = caller_context[
                constants.CTX_ALLOW_PROPERTY_WRITES]
        else:
            context[constants.CTX_NAMES_SCOPE] = obj_type
        return context
Esempio n. 5
0
 def create_package_context(self, package):
     context = super(ContextManager, self).create_package_context(
         package)
     if package.name == 'io.murano':
         context = helpers.link_contexts(
             context, yaql_functions.get_restricted_context())
     return context
Esempio n. 6
0
    def create_object_context(self, obj, caller_context=None):
        if isinstance(obj, dsl_types.MuranoClass):
            obj_type = obj
            obj = None
        else:
            obj_type = obj.type
        class_context = self.create_type_context(obj_type)
        if obj is not None:
            context = helpers.link_contexts(
                class_context, self.context_manager.create_object_context(
                    obj)).create_child_context()
            context[constants.CTX_THIS] = obj.real_this
            context['this'] = obj.real_this
            context[''] = obj.real_this
        else:
            context = class_context.create_child_context()
            type_ref = obj_type.get_reference()
            context[constants.CTX_THIS] = type_ref
            context['this'] = type_ref
            context[''] = type_ref

        if caller_context is not None:
            caller = caller_context
            while caller is not None and caller[constants.CTX_SKIP_FRAME]:
                caller = caller[constants.CTX_CALLER_CONTEXT]
            context[constants.CTX_NAMES_SCOPE] = caller_context[
                constants.CTX_NAMES_SCOPE]
            context[constants.CTX_CALLER_CONTEXT] = caller
            context[constants.CTX_ALLOW_PROPERTY_WRITES] = caller_context[
                constants.CTX_ALLOW_PROPERTY_WRITES]
        else:
            context[constants.CTX_NAMES_SCOPE] = obj_type
        return context
Esempio n. 7
0
 def create_root_context(self, runtime_version):
     root_context = super(TestContextManager, self).create_root_context(
         runtime_version)
     context = helpers.link_contexts(
         root_context, yaql_functions.get_context(runtime_version))
     context = context.create_child_context()
     for name, func in six.iteritems(self.__functions):
         context.register_function(func, name)
     return context
Esempio n. 8
0
 def create_root_context(self, runtime_version):
     root_context = super(TestContextManager,
                          self).create_root_context(runtime_version)
     context = helpers.link_contexts(
         root_context, yaql_functions.get_context(runtime_version))
     context = context.create_child_context()
     for name, func in self.__functions.items():
         context.register_function(func, name)
     return context
Esempio n. 9
0
 def create_class_context(self, murano_class):
     package_context = self.create_package_context(
         murano_class.package)
     context = helpers.link_contexts(
         package_context,
         self.context_manager.create_class_context(
             murano_class)).create_child_context()
     context[constants.CTX_TYPE] = murano_class
     return context
Esempio n. 10
0
 def create_type_context(self, murano_type):
     package_context = self.create_package_context(
         murano_type.package)
     context = helpers.link_contexts(
         package_context,
         self.context_manager.create_type_context(
             murano_type)).create_child_context()
     context[constants.CTX_TYPE] = murano_type
     return context
Esempio n. 11
0
    def create_object_context(self, murano_obj):
        original_context = super(MockContextManager,
                                 self).create_object_context(murano_obj)

        mock_context = self._create_new_ctx_for_obj(murano_obj.type.name)
        if mock_context:
            result_context = helpers.link_contexts(
                original_context, mock_context).create_child_context()
        else:
            result_context = original_context
        return result_context
    def create_object_context(self, murano_obj):
        original_context = super(MockContextManager,
                                 self).create_object_context(murano_obj)

        mock_context = self._create_new_ctx_for_obj(murano_obj.type.name)
        if mock_context:
            result_context = helpers.link_contexts(
                original_context, mock_context).create_child_context()
        else:
            result_context = original_context
        return result_context
Esempio n. 13
0
 def create_type_context(self, murano_type, caller_context=None):
     package_context = self.create_package_context(murano_type.package)
     context = helpers.link_contexts(
         package_context,
         self.context_manager.create_type_context(
             murano_type)).create_child_context()
     context[constants.CTX_TYPE] = murano_type
     if caller_context:
         context[constants.CTX_NAMES_SCOPE] = caller_context[
             constants.CTX_NAMES_SCOPE]
     return context
Esempio n. 14
0
 def create_type_context(self, murano_type, caller_context=None):
     package_context = self.create_package_context(
         murano_type.package)
     context = helpers.link_contexts(
         package_context,
         self.context_manager.create_type_context(
             murano_type)).create_child_context()
     context[constants.CTX_TYPE] = murano_type
     if caller_context:
         context[constants.CTX_NAMES_SCOPE] = caller_context[
             constants.CTX_NAMES_SCOPE]
     return context
Esempio n. 15
0
    def context(self):
        if not self._context:
            ctx = None
            for imp in reversed(self._imports):
                if ctx is None:
                    ctx = imp.exported_context
                else:
                    ctx = helpers.link_contexts(ctx, imp.exported_context)

            if ctx is None:
                self._context = yaql_integration.create_empty_context()
            else:
                self._context = ctx.create_child_context()

            for m in self._iterate_unique_methods():
                if m.instance_stub:
                    self._context.register_function(
                        m.instance_stub, name=m.instance_stub.name)
                if m.static_stub:
                    self._context.register_function(
                        m.static_stub, name=m.static_stub.name)
        return self._context
Esempio n. 16
0
    def context(self):
        if not self._context:
            ctx = None
            for imp in reversed(self._imports):
                if ctx is None:
                    ctx = imp.exported_context
                else:
                    ctx = helpers.link_contexts(ctx, imp.exported_context)

            if ctx is None:
                self._context = yaql_integration.create_empty_context()
            else:
                self._context = ctx.create_child_context()

            for m in self._iterate_unique_methods():
                if m.instance_stub:
                    self._context.register_function(
                        m.instance_stub, name=m.instance_stub.name)
                if m.static_stub:
                    self._context.register_function(
                        m.static_stub, name=m.static_stub.name)
        return self._context
Esempio n. 17
0
def op_dot_static(context, sender, expr, operator):
    executor = helpers.get_executor(context)
    type_context = executor.context_manager.create_class_context(sender.murano_class)
    ctx2 = helpers.link_contexts(context, type_context)
    return operator(ctx2, None, expr)
Esempio n. 18
0
 def create_package_context(self, package):
     root_context = self.create_root_context(package.runtime_version)
     context = helpers.link_contexts(
         root_context,
         self.context_manager.create_package_context(package))
     return context
Esempio n. 19
0
 def create_root_context(self, runtime_version):
     root_context = super(ContextManager,
                          self).create_root_context(runtime_version)
     return helpers.link_contexts(
         root_context, yaql_functions.get_context(runtime_version))
Esempio n. 20
0
 def create_root_context(self, runtime_version):
     root_context = super(ContextManager, self).create_root_context(
         runtime_version)
     return helpers.link_contexts(
         root_context, yaql_functions.get_context(runtime_version))
Esempio n. 21
0
def op_dot_static(context, receiver, expr, operator):
    executor = helpers.get_executor(context)
    type_context = executor.context_manager.create_type_context(
        receiver.type)
    ctx2 = helpers.link_contexts(context, type_context)
    return operator(ctx2, receiver, expr)
Esempio n. 22
0
 def create_package_context(self, package):
     root_context = self.create_root_context(package.runtime_version)
     context = helpers.link_contexts(
         root_context, self.context_manager.create_package_context(package))
     return context