コード例 #1
0
ファイル: Cgen.java プロジェクト: Evoludo/InsenseCompilerUnix
 public void channel(IDecl loc, ChannelType ct) {
   currentCode.append(Code.channelConstructorName(ct));
   // TODO JL Space Tracking
   ICode call_stack = findEnclosingDelcarationContainer();
   call_stack.track_call_space(MSP430Sizes.channelCreateCallOverhead());
 }
コード例 #2
0
  /* (non-Javadoc)
   * @see uk.ac.stand.cs.insense.compiler.Ccgen.IConnect#complete()
   */
  public void complete() {
    sb.append(NEWLINE + GENERATED_FROM + Diagnostic.getMethodInCallChain() + NEWLINE);

    String ex_handler = "";
    if (in_try_block) {
      ex_handler = AMPERSAND + "ex_handler";
    } else {
      if (context == ISymbolTable.FUNCTION) {
        ex_handler = "ex_handler";
      } else {
        ex_handler = NULL;
      }
    }

    ICode container_stack = Cgen.get_instance().findEnclosingDelcarationContainer();
    int connect_call_overhead = MSP430Sizes.sysFunctionCallOverhead(5 * MSP430Sizes.WORD_SIZE);
    int connect_stack_usage = MSP430Sizes.channelBindCallOverhead();

    if (!is_inter_node_channel[0] && is_inter_node_channel[1]) {
      sb.append(
          TAB
              + functionCall(
                  "remoteAnonymousBind_proc",
                  channel_fragments.get(0).toString(),
                  channel_fragments.get(2).toString(),
                  channel_fragments.get(1).toString(),
                  functionCall("Construct_String0", "\"" + channel_type[0].toStringRep() + "\""),
                  ex_handler)
              + SEMI
              + NEWLINE);
      connect_stack_usage = MSP430Sizes.INCH_CONNECT_STACK_USE;
    } else if (is_inter_node_channel[0] && !is_inter_node_channel[1]) {
      sb.append(
          TAB
              + functionCall(
                  "remoteAnonymousBind_proc",
                  channel_fragments.get(2).toString(),
                  channel_fragments.get(1).toString(),
                  channel_fragments.get(0).toString(),
                  functionCall("Construct_String0", "\"" + channel_type[1].toStringRep() + "\""),
                  ex_handler)
              + SEMI
              + NEWLINE);
      connect_stack_usage = MSP430Sizes.INCH_CONNECT_STACK_USE;
      container_stack.track_call_space(connect_call_overhead + connect_stack_usage);
    } else if (is_inter_node_channel[0] && is_inter_node_channel[1]) {
      sb.append(TAB + "// Connect 2 remote public channels" + NEWLINE);
      sb.append(
          TAB
              + functionCall(
                  "remoteBindRemotely_proc",
                  channel_fragments.get(1).toString(),
                  channel_fragments.get(0).toString(),
                  channel_fragments.get(3).toString(),
                  channel_fragments.get(2).toString(),
                  ex_handler)
              + SEMI
              + NEWLINE);
      connect_stack_usage = MSP430Sizes.INCH_REMOTE_CONNECT_STACK_USE;
      container_stack.track_call_space(connect_call_overhead + connect_stack_usage);
    } else if (!(is_inter_node_channel[0] || is_inter_node_channel[1])) {
      // Both channels are local
      sb.append(
          TAB
              + functionCall(
                  "channel_bind",
                  channel_fragments.get(0).toString(),
                  channel_fragments.get(1).toString())
              + SEMI
              + NEWLINE);
    }

    container_stack.track_call_space(connect_call_overhead + connect_stack_usage);
    super.append(NEWLINE + sb.toString());
  }