[m-rev.] for review: add --erlang-native-code and document erlang options

Peter Wang wangp at students.csse.unimelb.edu.au
Mon Jul 9 11:30:31 AEST 2007


Estimated hours taken: 1
Branches: main

compiler/options.m:
doc/user_guide.texi:
	Add an option `--erlang-native-code'.

	Document Erlang-related options.

compiler/compile_target_code.m:
	Pass +native to the Erlang compiler if --erlang-native-code is enabled.


Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.112
diff -u -r1.112 compile_target_code.m
--- compiler/compile_target_code.m	14 Jun 2007 11:51:33 -0000	1.112
+++ compiler/compile_target_code.m	9 Jul 2007 01:20:19 -0000
@@ -937,7 +937,15 @@
     maybe_write_string(Verbose, ErlangFile, !IO),
     maybe_write_string(Verbose, "':\n", !IO),
     globals.io_lookup_string_option(erlang_compiler, ErlangCompiler, !IO),
-    globals.io_lookup_accumulating_option(erlang_flags, ErlangFlagsList, !IO),
+    globals.io_lookup_accumulating_option(erlang_flags, ErlangFlagsList0, !IO),
+    globals.io_lookup_bool_option(erlang_native_code, ErlangNativeCode, !IO),
+    (
+        ErlangNativeCode = yes,
+        ErlangFlagsList = ["+native" | ErlangFlagsList0]
+    ;
+        ErlangNativeCode = no,
+        ErlangFlagsList = ErlangFlagsList0
+    ),
     ERLANGFLAGS = string.join_list(" ", ErlangFlagsList),
 
     globals.io_lookup_bool_option(use_subdirs, UseSubdirs, !IO),
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.572
diff -u -r1.572 options.m
--- compiler/options.m	2 Jul 2007 05:49:32 -0000	1.572
+++ compiler/options.m	9 Jul 2007 01:20:20 -0000
@@ -717,6 +717,7 @@
     ;       erlang_flags
     ;       quoted_erlang_flag
     ;       erlang_object_file_extension
+    ;       erlang_native_code
 
     % Link options
     ;       output_file_name
@@ -1484,7 +1485,8 @@
     erlang_interpreter                  -   string("erl"),
     erlang_flags                        -   accumulating([]),
     quoted_erlang_flag                  -   string_special,
-    erlang_object_file_extension        -   string(".beam")
+    erlang_object_file_extension        -   string(".beam"),
+    erlang_native_code                  -   bool(no)
 ]).
 option_defaults_2(link_option, [
     % Link Options
@@ -2304,6 +2306,7 @@
 long_option("erlang-flags",         erlang_flags).
 long_option("erlang-flag",          quoted_erlang_flag).
 long_option("erlang-object-file-extension", erlang_object_file_extension).
+long_option("erlang-native-code",   erlang_native_code).
 
 % link options
 long_option("output-file",          output_file_name).
@@ -3613,7 +3616,8 @@
         "--target asm\t\t\t(grades: hlc)",
         "--target il\t\t\t(grades: il)",
         "--target java\t\t\t(grades: java)",
-        "\tSpecify the target language: C, assembler, IL or Java.",
+        "--target erlang\t\t\t(grades: erlang)",
+        "\tSpecify the target language: C, assembler, IL, Java or Erlang.",
         "\tThe default is C.  ""IL"" (also known as ""CIL"" or ""MSIL"")",
         "\tis the Intermediate Language for the .NET Common Language",
         "\tRuntime.",
@@ -3621,7 +3625,7 @@
         "\tAs an exception to the usual rule for options in this section,",
         "\twhere different option settings normally correspond to different",
         "\tABIs, code generated using `--target asm' is binary compatible",
-        "\twith code generated using `--target c --high-level code', so",
+        "\twith code generated using `--target c --high-level-code', so",
         "\tthese both use grade `hlc'.",
         "--il",
         "\tAn abbreviation for `--target il'.",
@@ -3648,6 +3652,13 @@
         "\tGenerate Java code in `<module>.java', but do not generate",
         "\tobject code.",
 
+        "--erlang",
+        "\tAn abbreviation for `--target erlang'.",
+        "--erlang-only",
+        "\tAn abbreviation for `--target erlang --target-code-only'.",
+        "\tGenerate Erlang code in `<module>.erl', but do not generate",
+        "\tobject code.",
+
         "--compile-to-c",
         "\tAn abbreviation for `--target c --target-code-only'.",
         "\tGenerate C code in `<module>.c', but do not generate object",
@@ -3725,7 +3736,7 @@
     write_tabbed_lines([
         "--gc {none, boehm, mps, accurate, automatic}",
         "--garbage-collection {none, boehm, mps, accurate, automatic}",
-        "\t\t\t\t(`java' and `il' grades use",
+        "\t\t\t\t(`java', `il' and `erlang' grades use",
         "\t\t\t\t\t`--gc automatic',",
         "\t\t\t\t`.gc' grades use `--gc boehm',",
         "\t\t\t\t`.mps' grades use `--gc mps',",
@@ -4686,7 +4697,24 @@
         "--csharp-flags <options>, --csharp-flag <option>",
         "\tSpecify options to be passed to the C# compiler.",
         "\t`--csharp-flag' should be used for single words which need",
-        "\tto be quoted when passed to the shell."
+        "\tto be quoted when passed to the shell.",
+
+        "--erlang-compiler <erlc>",
+        "\tSpecify the name of the Erlang compiler.  The default is `erlc'.",
+        "--erlang-interpreter <erl>",
+        "\tSpecify the name of the Erlang interpreter.  The default is `erl'.",
+        "--erlang-flags <options>, --erlang-flag <option>",
+        "\tSpecify options to be passed to the Erlang compiler.",
+        "\t`--erlang-flag' should be used for single words which need",
+        "\tto be quoted when passed to the shell.",
+        "--erlang-native-code",
+        "\tAdd `+native' to the start of flags passed to the Erlang compiler.",
+        "\tCancelled out by `--no-erlang-native-code' so it's useful when you",
+        "\twish to enable native code generation for all modules except for",
+        "\ta select few."
+
+        % --erlang-object-file-extension is deliberately not documented.
+        % It is not fully implemented and not very useful.
     ]).
 
 :- pred options_help_link(io::di, io::uo) is det.
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.532
diff -u -r1.532 user_guide.texi
--- doc/user_guide.texi	2 Jul 2007 05:49:33 -0000	1.532
+++ doc/user_guide.texi	9 Jul 2007 01:20:24 -0000
@@ -200,9 +200,10 @@
 files associated with the module are used as timestamp files;
 they are used when deciding whether the interface files need to be regenerated.
 
- at file{.c_date}, @file{.il_date}, @file{.java_date},
+ at file{.c_date}, @file{.il_date}, @file{.java_date}, @file{.erl_date},
 @file{.s_date} and @file{.pic_s_date} files
 perform a similar function for @file{.c}, @file{.il}, @file{.java},
+ at file{.erl},
 @file{.s} and @file{.pic_s} files respectively. When smart recompilation
 (@pxref{Auxiliary output options}) works out that a module
 does not need to be recompiled, the timestamp file for the
@@ -237,6 +238,10 @@
 @file{.il} files are Intermediate Language (IL) files
 for the .NET Common Language Runtime.
 @c XXX mention .dll and .exe?
+ at file{.erl} and @file{.beam} files are Erlang source code and
+bytecode (object) files respectively.
+ at file{.beams} directories are collections of @file{.beam} files which
+act like a library archive.
 
 @c ----------------------------------------------------------------------------
 
@@ -553,6 +558,12 @@
 
 @c XXX mention .dlls and .exe targets?
 
+ at item @var{main-module}.erls
+Compiles @var{main-module} to Erlang source files (@file{*.erl}).
+
+ at item @var{main-module}.beams
+Compiles @var{main-module} to Erlang bytecode (object) files (@file{*.beam}).
+
 @item lib at var{main-module}
 Builds a library whose top-level module is @var{main-module}.
 This will build a static object library, a shared object library
@@ -920,6 +931,7 @@
 * Building with mmc --make::
 * Building with Mmake::
 * Libraries and the Java grade::
+* Libraries and the Erlang grade::
 @end menu
 
 @node Writing libraries
@@ -1313,6 +1325,19 @@
 file in your @samp{CLASSPATH}, which you can set using
 @samp{--java-classpath @var{jarfile}} in @samp{MCFLAGS}.
 
+ at node Libraries and the Erlang grade
+ at section Libraries and the Erlang grade
+ at cindex .beams directories
+ at cindex Erlang libraries
+
+Since the Erlang implementation does not have library files, the Mercury
+compiler puts all the @file{.beam} files for a single Mercury library into a
+directory named @file{lib at var{library-name}.beams}.
+
+To create or install an Erlang "library", specify that you want to use
+the erlang grade and use @samp{mmc --make}.  Mmake does not, at present,
+support Erlang targets.
+
 @c ----------------------------------------------------------------------------
 
 @node Debugging
@@ -6558,7 +6583,8 @@
 @findex --target-code-only
 Generate target code (i.e.@: C in @file{@var{module}.c},
 assembler in @file{@var{module}.s} or @file{@var{module}.pic_s},
-IL in @file{@var{module}.il} or Java in @file{@var{module}.java}),
+IL in @file{@var{module}.il}, Java in @file{@var{module}.java}
+or Erlang in @file{@var{module}.erl}),
 but not object code.
 
 @sp 1
@@ -7085,6 +7111,7 @@
 @cindex hlc (compilation grade)
 @cindex il (compilation grade)
 @cindex java (compilation grade)
+ at cindex erlang (compilation grade)
 @cindex .prof (grade modifier)
 @cindex .memprof (grade modifier)
 @cindex .profdeep (grade modifier)
@@ -7111,7 +7138,8 @@
 @table @asis
 @item What target language to use, what data representation to use, and (for C) what combination of GNU C extensions to use:
 @samp{none}, @samp{reg}, @samp{jump}, @samp{asm_jump},
- at samp{fast}, @samp{asm_fast}, @samp{hl}, @samp{hlc}, @samp{il} and @samp{java}
+ at samp{fast}, @samp{asm_fast}, @samp{hl}, @samp{hlc}, @samp{il}, @samp{java} and
+ at samp{erlang}
 (the default is system dependent).
 
 @item What garbage collection strategy to use:
@@ -7168,6 +7196,7 @@
 @findex --target
 @findex --il
 @findex --java
+ at findex --erlang
 @findex --gc
 @findex --profiling
 @findex --memory-profiling
@@ -7205,6 +7234,9 @@
 @item @samp{java}
 @code{--target java --high-level-code --high-level-data}.
 
+ at item @samp{erlang}
+ at code{--target erlang}.
+
 @item @samp{.gc}
 @code{--gc boehm}.
 
@@ -7272,11 +7304,13 @@
 @item @code{--target asm} (grades: hlc)
 @itemx @code{--il}, @code{--target il} (grades: il)
 @itemx @code{--java}, @code{--target java} (grades: java)
-Specify the target language used for compilation: C, assembler, IL or Java.
+ at itemx @code{--erlang}, @code{--target erlang} (grades: erlang)
+Specify the target language used for compilation: C, assembler, IL, Java
+or Erlang.
 C means ANSI/ISO C, optionally with GNU C extensions (see below).
 IL means the Intermediate Language of the .NET Common Language Runtime.
 (IL is sometimes also known as "CIL" or "MSIL".)
-Targets other than C imply @samp{--high-level-code}.
+Targets other than C and Erlang imply @samp{--high-level-code}.
 
 @sp 1
 @item @code{--il-only}
@@ -7316,6 +7350,13 @@
 Generate Java code in @file{@var{module}.java}, but do not invoke
 the Java compiler to produce Java bytecode.
 
+ at sp 1
+ at item @code{--erlang-only}
+ at findex --erlang-only
+An abbreviation for @samp{--target erlang --target-code-only}.
+Generate Erlang code in @file{@var{module}.erl}, but do not invoke
+the Erlang compiler to produce Erlang bytecode.
+
 @end table
 
 @node LLDS back-end compilation model options
@@ -7495,7 +7536,8 @@
 @findex --gc
 @findex --garbage-collection
 Specify which method of garbage collection to use.
-Grades containing @samp{java} or @samp{il} use @samp{--gc automatic},
+Grades containing @samp{java}, @samp{il} or @samp{erlang} use
+ at samp{--gc automatic},
 grades containing @samp{.gc} use @samp{--gc boehm},
 grades containing @samp{.mps} use @samp{--gc mps},
 other grades use @samp{--gc none}.
@@ -8942,6 +8984,36 @@
 Specify an extension for Java object (bytecode) files.  By default this
 is @samp{.class}.
 
+ at sp 1
+ at item --erlang-compiler @var{compiler-name}
+ at findex --erlang-compiler
+ at cindex Erlang compiler
+Specify which Erlang compiler to use.  The default is @samp{erlc}.
+
+ at sp 1
+ at item --erlang-interpreter @var{interpreter-name}
+ at findex --erlang-interpreter
+ at cindex Erlang interpreter
+Specify which Erlang interpreter to use.  The default is @samp{erl}.
+
+ at sp 1
+ at item --erlang-flags @var{options}
+ at itemx --erlang-flag @var{option}
+ at findex --erlang-flags
+ at findex --erlang-flag
+ at cindex Erlang compiler options
+Specify options to be passed to the Erlang compiler.
+ at samp{--erlang-flag} should be used for single words which need
+to be quoted when passed to the shell.
+
+ at c This option is not fully implemented and not very useful.
+ at c @sp 1
+ at c @item --erlang-object-file-extension @var{extension}
+ at c @findex --erlang-object-file-extension
+ at c @cindex File extensions
+ at c Specify an extension for Erlang object (bytecode) files.  By default this
+ at c is @samp{.beam}.
+
 @end table
 
 @node Link options
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list