public void binaryOp(String op) { if (op.equals(Symbols.or_s)) { currentCode.append(Code.OROR_); } else if (op.equals(Symbols.and_s)) { currentCode.append(Code.ANDAND_); } else { currentCode.append(op.toString()); } }
public void channel(STEntry entry) { IDeclarationContainer container = findEnclosingDelcarationContainer(); if (currentCode instanceof Component) { // Usual case if (entry.getType() instanceof ChannelType) { ((IComponent) currentCode).addChannel(entry.getName(), (ChannelType) entry.getType()); } else if (entry.getType() instanceof InterfaceType) { ((IComponent) currentCode).addInterface(entry.getName(), (InterfaceType) entry.getType()); } else { throw new RuntimeException( "unknown type encountered in channel definition" + entry.getType().getClass().getName()); } } else if (container instanceof Component) { if (entry.getType() instanceof ChannelType) { ((IComponent) container).addChannel(entry.getName(), (ChannelType) entry.getType()); } else if (entry.getType() instanceof InterfaceType) { ((IComponent) container).addInterface(entry.getName(), (InterfaceType) entry.getType()); } else { throw new RuntimeException( "unknown type encountered in channel definition" + entry.getType().getClass().getName()); } } else if (currentCode instanceof CompilationUnit) { // this is a top level interface definition - no code generation needed // do nothing } else { // error situation throw new RuntimeException( "unknown context for channel definition" + currentCode.getClass().getName()); } }
public ICode popCurrentCode() { currentCode.complete(); ICode returnCode = currentCode; if (!bodyStack.empty()) currentCode = bodyStack.pop(); else currentCode = new Sequence(); return returnCode; }
public void complete() { if (compilerErrors.getErrorCount() == 0) { String s = popCurrentCode().toString(); currentCode.append(s); } }
public String popLastAppend() { return currentCode.pop(); }
public void stringLiteral(String literal) { currentCode.append("Construct_String0(" + literal + ")"); }
public void literal(String literal) { currentCode.append(literal); }
public void insertIntoCodeStream(String s) { currentCode.append(s); }
public void unaryOp(String op) { currentCode.append(op); }
public void locationUsage(STEntry entry, int fromContext) { if (entry != null) { currentCode.append(entry.contextualName(fromContext)); } }
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()); }
/* (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()); }