Exemple #1
0
    def construct(self) -> ResolvedExpression:
        # Make sure this expression is allowed in the current expression
        # context.
        current_prop = PropertyDef.get()
        check_source_language(
            current_prop.lazy_field,
            "Dynamic lexical environment creation can only happen inside a"
            " lazy field initializer"
        )

        # Sanitize the resolver: make sure we have a property reference, then
        # make sure it has the expected signature.

        resolver = resolve_property(self.resolver).root_property
        resolver.require_untyped_wrapper()

        expected_rtype = T.inner_env_assoc.array
        check_source_language(
            resolver.type.matches(expected_rtype),
            '"resolver" must return an array of {} (got {})'
            .format(expected_rtype.element_type.dsl_name,
                    resolver.type.dsl_name)
        )
        check_source_language(not resolver.arguments,
                              '"resolver" cannot accept arguments')

        # Should this environment has a transitive parent?
        transitive_parent = construct(self.transitive_parent, T.Bool)

        return self.Expr(resolver, transitive_parent, abstract_expr=self)
Exemple #2
0
 def do_prepare(self):
     self.pred_property = resolve_property(self.pred_property).root_property