Beispiel #1
0
  Object* BlockEnvironment::call_under(STATE,CallFrame* call_frame,
                                       Executable* exec, Module* mod,
                                       Arguments& args)
  {
    if(args.total() < 2) {
      Exception* exc =
        Exception::make_argument_error(state, 2, args.total(),
                                       state->symbol("__block__"));
      exc->locations(state, Location::from_call_stack(state, call_frame));
      state->raise_exception(exc);
      return NULL;
    }

    Object* recv = args.shift(state);
    ConstantScope* constant_scope = as<ConstantScope>(args.shift(state));

    BlockInvocation invocation(recv, constant_scope, 0);
    return invoke(state, call_frame, this, args, invocation);
  }
  Object* BlockEnvironment::call_under(STATE, CallFrame* call_frame,
                                       Executable* exec, Module* mod,
                                       Arguments& args)
  {
    if(args.total() < 3) {
      Exception* exc =
        Exception::make_argument_error(state, 3, args.total(),
                                       compiled_code_->name());
      exc->locations(state, Location::from_call_stack(state, call_frame));
      state->raise_exception(exc);
      return NULL;
    }

    Object* recv = args.shift(state);
    ConstantScope* constant_scope = as<ConstantScope>(args.shift(state));
    Object* visibility_scope = args.shift(state);

    int flags = CBOOL(visibility_scope) ? CallFrame::cTopLevelVisibility : 0;
    BlockInvocation invocation(recv, constant_scope, flags);
    return invoke(state, call_frame, this, args, invocation);
  }
	void FDFireflyIceTaskSteps::fireflyIcePing(std::shared_ptr<FDFireflyIce> fireflyIce, std::shared_ptr<FDFireflyIceChannel> channel, std::vector<uint8_t> data)
	{
		//    FDFireflyDeviceLogDebug(@"ping received");
		FDBinary binary(data);
		uint32_t invocationId = binary.getUInt32();
		if (invocationId != _invocationId) {
			FDFireflyDeviceLogWarn("unexpected ping 0x%08x (expected 0x%08x)", invocationId, _invocationId);
			return;
		}

		if (_invocation != nullptr) {
			//        FDFireflyDeviceLogDebug(@"invoking step %@", NSStringFromSelector(_invocation.selector));
			std::function<void()> invocation = _invocation;
			_invocation = nullptr;
			invocation();
		}
		else {
			//        FDFireflyDeviceLogDebug(@"all steps completed");
			fireflyIce->executor->complete(shared_from_this());
		}
	}
Beispiel #4
0
void TestErrorDetection::test_invalid_month_name() {

    std::set<std::string> valid_names(months, months + 12);

    pattern = valid_pattern;
    for (int b0 = 0; b0 < 256; b0++) {
        pattern[MONTH0] = b0;
        for (int b1 = 0; b1 < 256; b1++) {
            pattern[MONTH1] = b1;
            for (int b2 = 0; b2 < 256; b2++) {
                pattern[MONTH2] = b2;
                const auto ret = invocation();
                if (ret < 0)
                    continue;

                std::string tmp = pattern.substr(8, 3);
                if (valid_names.count(tmp) == 0) {
                    printf("b0, b1, b2 = {%02x, %02x, %02x}\n", b0, b1, b2);
                    throw TestFailed{"'" + tmp + "' is not a valid month name"};
                }
            }
        }
    }
}
 Object* BlockEnvironment::call(STATE, CallFrame* call_frame,
                                Arguments& args, int flags)
 {
   BlockInvocation invocation(scope_->self(), constant_scope_, flags);
   return invoke(state, call_frame, this, args, invocation);
 }
Beispiel #6
0
InvocationResult WebPage::invokeCapybaraFunction(const char *name, bool allowUnattached, const QStringList &arguments) {
  QString qname(name);
  JavascriptInvocation invocation(qname, allowUnattached, arguments, this);
  return invocation.invoke(currentFrame());
}
Beispiel #7
0
		void Invoke( TArgn&&... argn ) {
			static_assert( sizeof...( TArgn ) == sizeof...( Tn ), "Event must be called with the right amount of parameters." );
			for ( auto& invocation : invocations ) 
				invocation( std::forward<TArgn>( argn )... );
		}
Beispiel #8
0
 Object* BlockEnvironment::call(STATE, CallFrame* call_frame, Arguments& args, int flags) {
   BlockInvocation invocation(scope_->self(), method_->scope(), flags);
   return (*execute)(state, call_frame, this, args, invocation);
 }
Beispiel #9
0
		void Invoke ( T0&& t0, T1&& t1 ) {
			for ( auto& invocation : invocations ) {
				invocation( std::forward<T1>( t0 ), std::forward<T1>( t1 ) );
			}
		}
  Object* BlockAsMethod::block_executor(STATE, Executable* exec, Module* mod,
                                       Arguments& args)
  {
    BlockAsMethod* bm = as<BlockAsMethod>(exec);

    Fixnum* splat = bm->block_env()->compiled_code()->splat();
    size_t required = bm->block_env()->compiled_code()->required_args()->to_native();
    size_t total_args = bm->block_env()->compiled_code()->total_args()->to_native();

    /*
     * These are the block shapes, required args, and splat that we may see,
     * along with the arity check that we must perform:
     *
     *   block shape   required args   splat   check
     *  -------------|---------------|-------|-------
     *  { || }       |  0            |  nil  |  ==
     *  {  }         |  0            |  -2   |  none
     *  { |a| }      |  1            |  nil  |  none (1.8), == (>= 1.9)
     *  { |*a| }     |  0            |  0    |  none
     *  { |a, b| }   |  2            |  nil  |  ==
     *  { |a, *b| }  |  1            |  1    |  >=
     *
     * NOTE that when taking one argument, any arguments passed are put
     * into an array and the local gets the array (or an empty array if
     * no arguments are passed). This is handled by the bytecode prologue
     * of the block.
     */
    bool exception = false;
    size_t expected = 0;
    if(splat->nil_p()) {
      if(args.total() > total_args) {
        exception = true;
        expected = total_args;
      }
      if(args.total() < required) {
        exception = true;
        expected = required;
      }
    } else {
      if(required > args.total()) {
        exception = true;
        expected = required;
      }
    }

    if(exception) {
      Exception* exc =
        Exception::make_argument_error(state, expected, args.total(), args.name());
      exc->locations(state, Location::from_call_stack(state));
      state->raise_exception(exc);
      return NULL;
    }

    BlockInvocation invocation(args.recv(),
        bm->block_env()->lexical_scope(),
        CallFrame::cIsLambda | CallFrame::cBlockAsMethod);

    invocation.module = mod;

    return bm->block_env()->invoke(state,
                                   bm->block_env(), args, invocation);
  }
Beispiel #11
0
void RefactoringTool::run(const std::string& code,
                          clang::tooling::FrontendActionFactory *actionFactory)
{
  CustomToolInvocation invocation(code);
  run(invocation, actionFactory);
}
Beispiel #12
0
void TestBase::assume_invalid_invocation() {
    const int ret = invocation();
    if (ret == 0) {
        throw TestFailed{"Expected detection of error"};
    }
}
Beispiel #13
0
void TestBase::assume_valid_invocation() {
    const int ret = invocation();
    if (ret < 0) {
        throw TestFailed{"Expected proper conversion, got " + std::to_string(ret)};
    }
}