def call( self, args, env ):

        if all_known( args, env ):
            ui = self.user_interface.evaluate( env )
            cl = args[0].evaluate( env )
            return PepBool( ui.can_match( cl, env ) )
        else:
            raise Exception(
                "We don't (yet) allow checking interfaces at runtime." )
 def call( self, args, env ):
     if all_known( args + (self.instance,), env ):
         return self.fn.call( self._instance_plus_args( args ), env )
     else:
         return PepRuntimeUserFunction(
             self.fn,
             self._instance_plus_args( args ),
             self.instance.clazz.get_name()
         )
 def call( self, args, env ):
     if all_known( ( self.clazz,) + args, env ):
         evaldarg = args[0].evaluate( env )
         # TODO: check evaldarg is an interface (or at least has can_match)
         return PepBool( evaldarg.can_match( self.clazz, env ) )
     else:
         raise Exception(
             "Can't (currently) support checking whether classes " +
             "implement interfaces at runtime."
         )
Exemple #4
0
    def call( self, args, env ):
        """You  must call args_match first and only call this if the return
        value was True"""
        if all_known( args, env ):

            newenv = self.execution_environment( args, True, env )

            for stmt in self.body_stmts:
                ev_st = stmt.evaluate( newenv )
                if ev_st.__class__ == PepReturn:
                    return ev_st.value.evaluate( newenv )
            return PepPass()
        # TODO: if this is a pure function, could we partially-evaluate it?

        return PepRuntimeUserFunction( self, args, None )
Exemple #5
0
 def call( self, args, env ):
     if all_known( args, env ):
         ret = self.user_class.known_instance()
         if PepDefInit.INIT_IMPL_NAME in self.user_class.namespace:
             self.user_class.namespace[PepDefInit.INIT_IMPL_NAME].call(
                 (ret,) + args, env )
         # TODO: else default constructor
         return ret
     else:
         inst = PepVariable( self.user_class.evaluate( env ), "" )
         return PepRuntimeInit(
             inst,
             args,
             self.user_class.namespace[PepDefInit.INIT_IMPL_NAME].call(
                 (inst,) + args, env )
         )
Exemple #6
0
 def is_known(self, env):
     return all_known((self.var, self.mod_value), env)
 def is_known( self, env ):
     return all_known( self._list, env )