public static void main(String[] args) { System.out.println( BaseCompilerAssembly.MODULE_NAME + " version " + BaseCompilerAssembly.VERSION); Diagnostic.setLevel(DiagnosticLevel.RESULT); Diagnostic.trace(DiagnosticLevel.RUN, "Insense compiler running "); if (args.length == 0) { System.out.println(BaseCompilerAssembly.USAGE_MESSAGE); return; } try { String fileLocation = args[INPUT_FILE_INDEX]; String outputDirectory = null; if (args.length >= 2) outputDirectory = args[OUTPUT_DIRECTORY_INDEX]; ISourceRepresentation source = new SourceFile(fileLocation); OutputFile.setOutputDirectory(outputDirectory); String project_name = fileLocation; if (args.length >= 3) { project_name = args[PROJECT_NAME_INDEX]; } int errors = compile(source, project_name); if (errors == 0) { System.out.println("*** Program Compiles **** "); } else { System.out.println("*** Compilation fails, number of errors = " + errors + " **** "); } } catch (ArrayIndexOutOfBoundsException e) { usage(); } catch (Exception e) { e.printStackTrace(); } }
/* (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()); }