LCOV - code coverage report
Current view: top level - lib - options.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 8 100.0 %
Date: 2014-11-22 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* options.cpp -- written by Alexis WILKE for Made to Order Software Corp. (c) 2005-2014 */
       2             : 
       3             : /*
       4             : 
       5             : Copyright (c) 2005-2014 Made to Order Software Corp.
       6             : 
       7             : http://snapwebsites.org/project/as2js
       8             : 
       9             : Permission is hereby granted, free of charge, to any
      10             : person obtaining a copy of this software and
      11             : associated documentation files (the "Software"), to
      12             : deal in the Software without restriction, including
      13             : without limitation the rights to use, copy, modify,
      14             : merge, publish, distribute, sublicense, and/or sell
      15             : copies of the Software, and to permit persons to whom
      16             : the Software is furnished to do so, subject to the
      17             : following conditions:
      18             : 
      19             : The above copyright notice and this permission notice
      20             : shall be included in all copies or substantial
      21             : portions of the Software.
      22             : 
      23             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
      24             : ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
      25             : LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
      26             : FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
      27             : EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
      28             : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      29             : WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
      30             : ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      31             : SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      32             : SOFTWARE.
      33             : 
      34             : */
      35             : 
      36             : #include "as2js/options.h"
      37             : 
      38             : 
      39             : /** \file
      40             :  * \brief Implementation of the Options object.
      41             :  *
      42             :  * The Options object is used to carry all the options around the
      43             :  * entire set of functions used to compile AlexScript.
      44             :  */
      45             : 
      46             : 
      47             : namespace as2js
      48             : {
      49             : 
      50             : 
      51             : /** \enum Options::option_t
      52             :  * \brief The available options.
      53             :  *
      54             :  * This enumeration defines all the options available in the compiler.
      55             :  * Additional options may be available in the command line tool, but
      56             :  * these are all those supported in the code via the 'use' keyword
      57             :  * (i.e. pragma) and expected to be command line options to the
      58             :  * command line tool.
      59             :  */
      60             : 
      61             : 
      62             : /** \var Options::OPTION_UNKNOWN
      63             :  * \brief Unknown option, used as a fallback in different situations.
      64             :  *
      65             :  * This is not really an option. It is used as a fallback in a few
      66             :  * situations where some otion is required, but none is really
      67             :  * available to do the job.
      68             :  */
      69             : 
      70             : 
      71             : /** \var Options::OPTION_ALLOW_WITH
      72             :  * \brief Whether the 'with' keyword can be used.
      73             :  *
      74             :  * By default the 'with' keyword is forbidden by as2js. You must
      75             :  * explicitly allow it to use it with:
      76             :  *
      77             :  * \code
      78             :  *      use allow_with(1);
      79             :  * \endcode
      80             :  *
      81             :  * In general, the 'with' statement is considered as deprecated and
      82             :  * it should not be used because the order in which objects are checked
      83             :  * for a field found inside a with statement is undefined. Because of
      84             :  * that, it is not possible to make sure that code within a 'with'
      85             :  * statement does what it is expected to do.
      86             :  *
      87             :  * In other words, it is not secure.
      88             :  *
      89             :  * Note that if the compiler is set in strict mode, the 'with' statement
      90             :  * is not allowed, whether or not this flag is turned on.
      91             :  */
      92             : 
      93             : 
      94             : /** \var Options::OPTION_BINARY
      95             :  * \brief Whether binary numbers are allowed.
      96             :  *
      97             :  * By default, binary numbers are not supported. If this option
      98             :  * is turned on, then the compiler recognizes binary numbers.
      99             :  *
     100             :  * The syntax of a binary number is: ('0' 'b' ['0'-'1']+)
     101             :  *
     102             :  * For example, 170 in binary:
     103             :  *
     104             :  * \code
     105             :  *    a := 0b10101010;
     106             :  * \endcode
     107             :  *
     108             :  * JavaScript does not support the binary notation at all. However, the
     109             :  * introducer '0b' is not compatible is a welformed JavaScript source file.
     110             :  *
     111             :  * \note
     112             :  * The maximum number of digits allowed is 64. Note, however, that
     113             :  * JavaScript does not support 64 bit decimal numbers so some bits
     114             :  * will be lost on such large numbers.
     115             :  */
     116             : 
     117             : 
     118             : /** \var Options::OPTION_COVERAGE
     119             :  * \brief Whether coverage is requested.
     120             :  *
     121             :  * AlexScript includes the necessary support to generate coverage code.
     122             :  * This is used to know whether your tests are thorough and really test
     123             :  * all the code.
     124             :  *
     125             :  * It is possible that your code becomes very slow because of this option.
     126             :  * Code that you use in a loop or that generally needs to be fast may
     127             :  * require that you surround that code with pragmas to temporarilly turn
     128             :  * the coverage off:
     129             :  *
     130             :  * \code
     131             :  *      use coverage(0);
     132             :  *      function slow_stuff()
     133             :  *      {
     134             :  *         ...
     135             :  *      }
     136             :  *      use coverage(1);
     137             :  * \endcode
     138             :  *
     139             :  * A future version will allow you to push/pop the current status so you
     140             :  * do not have to delete the pragmas once done running your tests.
     141             :  *
     142             :  * \note
     143             :  * This has to be used with some AJAX code to retrieve the counters so
     144             :  * just turning on the coverage option is not enough.
     145             :  */
     146             : 
     147             : 
     148             : /** \var Options::OPTION_DEBUG
     149             :  * \brief Turn on debug features.
     150             :  *
     151             :  * AlexScript supports a set of debug features, which still need to
     152             :  * be implemented, to help you find problems in your code.
     153             :  *
     154             :  * The debug option turns on those features and autmoatically adds
     155             :  * debug code in the output so you can easily find problems in your
     156             :  * source.
     157             :  */
     158             : 
     159             : 
     160             : /** \var Options::OPTION_EXTENDED_ESCAPE_SEQUENCES
     161             :  * \brief Accept additional escape sequences in strings.
     162             :  *
     163             :  * This options authorizes the compiler to transform escape sequences that
     164             :  * are otherwise forbidden in JavaScript. The compiler will automatically
     165             :  * transform those to a valid supported value in the final output.
     166             :  *
     167             :  * The extensions are:
     168             :  *
     169             :  * \li "\UXXXXXXXX" -- support any Unicode character from 0 to 0x10FFFF.
     170             :  * Generate two \\uXXXX of encoded UTF-16 in the output.
     171             :  *
     172             :  * \li "\e" -- insert an escape character in the string (code 033).
     173             :  *
     174             :  * \li "\0XX" to "\7XX" -- support any octal character. JavaScript may
     175             :  * accept those. We transform them to \\uXXXX. Note that only ISO-8869-1
     176             :  * characters are accept as the number of digits is limited to 3 (i.e. to
     177             :  * a number between 0 and 255.)
     178             :  *
     179             :  * Note that "\0" is always accepted and it represents the NUL character.
     180             :  */
     181             : 
     182             : 
     183             : /** \var Options::OPTION_EXTENDED_OPERATORS
     184             :  * \brief Accept additional operators.
     185             :  *
     186             :  * AlexScript offers additional operators to cover some operations that
     187             :  * are fairly common in programming and most often annoying to write
     188             :  * by hand.
     189             :  *
     190             :  * When this option is turned off, those extended operators are
     191             :  * recognized so everything continues to compile, but the parser
     192             :  * generates errors on each one found. When this option is set to
     193             :  * a value other than zero, the extended operators are accepted.
     194             :  *
     195             :  * The supported extensions are:
     196             :  *
     197             :  * \li '**' and '**=' -- power and power assignment operators; these are
     198             :  * transforms to Math.pow(l, r);.
     199             :  *
     200             :  * \li '`...`' -- allow regular expressions to be written without the
     201             :  * use of the standard /.../ syntax which can be confused when used
     202             :  * improperly (i.e. the '/' is used by comments, divisions, assignments...)
     203             :  *
     204             :  * \li '::' -- the scope operator which may be removed at some point,
     205             :  * although there are still some cases where this operator can be used
     206             :  * and not the member (.) operator... (TBD)
     207             :  *
     208             :  * \li '~~', '~=' and '!~' -- the smart match, match, and not match
     209             :  * operators that are used to match a value (left hand side) to a
     210             :  * regular expression (right hand side). These are taken from perl,
     211             :  * although the '~=' is inverted because '=~' could legally also
     212             :  * mean 'a = ~b'.
     213             :  *
     214             :  * \li '<%', '<%=', '>%', and '>%=' -- rotate to the left and rotate to
     215             :  * the right. This are just convenient in AlexScript. Remember that
     216             :  * bitwise operations only work on 32 bits.
     217             :  *
     218             :  * \li 'in ...' -- test whether the left hand side fits in a specified range.
     219             :  * This is similar to the longer syntax (a >= min && a <= max).
     220             :  *
     221             :  * \li '<>' -- this is another way to write '!='
     222             :  *
     223             :  * \li ':=' -- this is another way to write '=', although we offer a way to
     224             :  * force the code to use ':=' only.
     225             :  *
     226             :  * \li '<=>' -- this operator is taken from perl, it returns -1, 0, or 1
     227             :  * as a comparison result (if l < r, return -1; if l == r, return 0; and
     228             :  * if l > r, return 1).
     229             :  *
     230             :  * \li '^^' and '^^=' -- the logical XOR operator and corresponding
     231             :  * assignment. This is similar to the && and ||, but somehow they do
     232             :  * not offer that operator in C/C++/JavaScript/Java, etc. Not too sure
     233             :  * why since it is a rather common operation to perform.
     234             :  *
     235             :  * \li '&&=' and '||=' -- the logical AND and OR assignments, which are
     236             :  * not offered in C/C++/JavaScript/Java... I think the main reason to
     237             :  * not offer such is because it could be viewed as being confusing. But
     238             :  * there is no reason not to have those operations.
     239             :  *
     240             :  * \li '<?', '<?=', '>?', and '>?=' -- the minimum and maximum operators,
     241             :  * as they were defined by g++ at some point.
     242             :  *
     243             :  * This option has an extended feature which is to use flag 1 as a mean
     244             :  * to authorize (0) or forbid (1) the use of the '=' character as the
     245             :  * assignment operator. In other words, the following code is normal
     246             :  * AlexScript code:
     247             :  *
     248             :  * \code
     249             :  *      a = 123;
     250             :  * \endcode
     251             :  *
     252             :  * which fails with an error when bit 1 of the OPTION_EXTENDED_OPERATORS
     253             :  * value is set. So the following will NOT compile:
     254             :  *
     255             :  * \code
     256             :  *      use extended_operators(3);
     257             :  *      a = 123;   // error here
     258             :  * \endcode
     259             :  *
     260             :  * There is another extended operator which is the Pascal assignment
     261             :  * operator: ':=', which must be used to replace the '=' operator.
     262             :  * This the statment we've just see can be rewritten as:
     263             :  *
     264             :  * \code
     265             :  *      use extended_operators(3);
     266             :  *      a := 123;   // that works!
     267             :  * \endcode
     268             :  *
     269             :  * The idea is simple: it is much less likely that you would mistakingly
     270             :  * use ':=' instead of '=='. Also, at some point we want to completely
     271             :  * forbid assignments in expressions and instead only allow them as
     272             :  * statements (as done in Ada and Pascal). This way you avoid potential
     273             :  * problems with lines of code such as:
     274             :  *
     275             :  * \code
     276             :  *      if(a = 3)
     277             :  *      {
     278             :  *          // do something
     279             :  *          b += 4;
     280             :  *          ...
     281             :  *      }
     282             :  * \endcode
     283             :  *
     284             :  * which is the same as:
     285             :  *
     286             :  * \code
     287             :  *      a = 3;
     288             :  *      b += 4;
     289             :  *      ...
     290             :  * \endcode
     291             :  *
     292             :  * since (a = 3) returns 3 and that is viewed as always true and
     293             :  * it is probably a bug. In other words, the programmer probably meant:
     294             :  *
     295             :  * \code
     296             :  *      if(a == 3)
     297             :  *      {
     298             :  *          // do somthing
     299             :  *          b += 4;
     300             :  *          ...
     301             :  *      }
     302             :  * \endcode
     303             :  *
     304             :  * With a feature saying that assignments have to be writte as statements,
     305             :  * the <code>if(a = 3)</code> statement is not legal because in that case
     306             :  * the assignment is in an expression.
     307             :  *
     308             :  * \note
     309             :  * At this point, use 2 or 3 as the option value has the same effect.
     310             :  */
     311             : 
     312             : 
     313             : /** \var Options::OPTION_EXTENDED_STATEMENTS
     314             :  * \brief Accept additional statement structures.
     315             :  *
     316             :  * AlexScript offers additional capabilities while parsing your code.
     317             :  *
     318             :  * The following is the list of statements that are available to you
     319             :  * when the extended statement option is set:
     320             :  *
     321             :  * \li 'case <expr> ... <expr>' -- support a range in a case. This is
     322             :  * the same as gcc/g++. The left and right expressions are inclusive.
     323             :  *
     324             :  * \li 'switch(<expr>) with(<expr>) ...' -- support the specification
     325             :  * of the switch operator using the 'with' keyword. Note that this use
     326             :  * of the 'with' keyword has nothing to do with the 'with' statement
     327             :  * and thus the OPTION_ALLOW_WITH and OPTION_STRICT have no effect
     328             :  * over this usage.
     329             :  *
     330             :  * This option can also have bit 1 set to trigger the 'force a block
     331             :  * of statements' here feature. When writing code, one can use one
     332             :  * liners such as:
     333             :  *
     334             :  * \code
     335             :  *      if(a)
     336             :  *          b = a.somefield;
     337             :  * \endcode
     338             :  *
     339             :  * This is all good until the programmer notices that he needs a
     340             :  * second line of code and writes:
     341             :  *
     342             :  * \code
     343             :  *      if(a)
     344             :  *          b = a.somefield;
     345             :  *          c = a.something_else;
     346             :  * \endcode
     347             :  *
     348             :  * As we can see, the second statement does not depend on the if()
     349             :  * BUT if you do not pay close attention, the fact that the curvly
     350             :  * brackets are missing may not be obvious. Bit 1 of the extended
     351             :  * statement option is used to force the programmer to use such
     352             :  * statements with curvly brackets, ALWAYS.
     353             :  *
     354             :  * Note that if you do not put the curvly brackets to save space
     355             :  * in the final JavaScript code, know that our assembler will do
     356             :  * that for you automatically. So you do not have to worry about
     357             :  * that in your AlexScript source code.
     358             :  *
     359             :  * \code
     360             :  *      // fine, the extension is turned off
     361             :  *      use extended_statements(0);
     362             :  *      if(a)
     363             :  *          b = a.somefield;
     364             :  *
     365             :  *      // error, the extension is turned on
     366             :  *      use extended_statements(2);
     367             :  *      if(a)
     368             :  *          b = a.somefield;
     369             :  *
     370             :  *      // fine, the programmer used the { ... }
     371             :  *      use extended_statements(2);
     372             :  *      if(a)
     373             :  *      {
     374             :  *          b = a.somefield;
     375             :  *      }
     376             :  * \endcode
     377             :  *
     378             :  * \note
     379             :  * At this point, use 2 or 3 as the option value has the same effect.
     380             :  */
     381             : 
     382             : 
     383             : /** \var Options::OPTION_JSON
     384             :  * \brief Change the lexer to read data for our JSON implementation.
     385             :  *
     386             :  * The js2as library includes a JSON parser. It will force this
     387             :  * option to 1 when using the lexer from that parser. This tells
     388             :  * the lexer that a certain number of characters (such as 0x2028)
     389             :  * are to be viewed as standard characters instead of specialized
     390             :  * characters.
     391             :  *
     392             :  * \todo
     393             :  * This is not yet fully implemented.
     394             :  */
     395             : 
     396             : 
     397             : /** \var Options::OPTION_OCTAL
     398             :  * \brief Whether octal numbers are allowed.
     399             :  *
     400             :  * By default, octal numbers are not supported. If this option
     401             :  * is turned on, then the compiler recognizes octal numbers.
     402             :  *
     403             :  * The syntax of an octal number is: ('0' ['0'-'7']+)
     404             :  *
     405             :  * For example, 170 in octal:
     406             :  *
     407             :  * \code
     408             :  *    a := 0252;
     409             :  * \endcode
     410             :  *
     411             :  * JavaScript does supports the octal notation. However, it is forbidden
     412             :  * in strict mode and it is not considered safe so we only use decimal
     413             :  * numbers in the output.
     414             :  *
     415             :  * \note
     416             :  * AlexScript accepts up to 22 digits in octal numbers. This allows you
     417             :  * to write a 64 bit decimal number. Remember, though, that JavaScript
     418             :  * does not support 64 bit decimals. Some of the digits will be lost.
     419             :  */
     420             : 
     421             : 
     422             : /** \var Options::OPTION_STRICT
     423             :  * \brief Whether strict mode is turned on.
     424             :  *
     425             :  * By defaut, just like JavaScript, the compiler accepts 'weak' code
     426             :  * practices. This option turns on the strict mode of AlexScript.
     427             :  *
     428             :  * Note that by default AlexScript is already way strictier than the
     429             :  * standard JavaScript. For example, semi-colons are required everywhere.
     430             :  * On the other hand, AlexScript allows break and return statements to
     431             :  * be written on multiple lines.
     432             :  *
     433             :  * The following is legal code, even in strict mode:
     434             :  *
     435             :  * \code
     436             :  *      return
     437             :  *          a
     438             :  *          *
     439             :  *          3
     440             :  *      ;
     441             :  *
     442             :  *      break
     443             :  *          outside
     444             :  *      ;
     445             :  * \endcode
     446             :  *
     447             :  * We may look into fixing these, although the only reason for JavaScript
     448             :  * to disallow this syntax is to allow missing semi-colons so it is not
     449             :  * really important. We will always output semi-colons after each line
     450             :  * in our output.
     451             :  */
     452             : 
     453             : 
     454             : /** \var Options::OPTION_TRACE
     455             :  * \brief Turn on trace mode.
     456             :  *
     457             :  * This option requests that trace mode be turned on.
     458             :  *
     459             :  * Trace mode is a feature from AlexScript which adds code to trace
     460             :  * each "statement" just before it gets executed. We put statement between
     461             :  * quotes because in many cases it is more like a line of code (i.e. an
     462             :  * if(...) statement includes the block of statements, the else and the
     463             :  * blocks following the else, and in that case the trace only shows the
     464             :  * if() and its expression.)
     465             :  *
     466             :  * The trace feature makes use the Trace package which can be tweaked
     467             :  * to your liking. The Trace object records the information from the
     468             :  * original source file such as the line number, file name, options,
     469             :  * etc.
     470             :  */
     471             : 
     472             : 
     473             : /** \var Options::OPTION_UNSAFE_MATH
     474             :  * \brief Tell the optimizer whether to apply unsafe mathematical optimizations.
     475             :  *
     476             :  * Many operations in JavaScript look like they can be optimized. For example:
     477             :  *
     478             :  * \code
     479             :  *      a := a | 0;
     480             :  *      a := a & -1;
     481             :  *      a := ~~a;
     482             :  *      a := a * 1;
     483             :  *      a := a + '';
     484             :  * \endcode
     485             :  *
     486             :  * All of these operations have side effects. The bitwise operations
     487             :  * first transform the contents of variable 'a' to 32 bits integer,
     488             :  * then apply the operation, and finally save the result back in a
     489             :  * double. In other words, the bitwise operations presented here are
     490             :  * equivalent to <code>a &= 0xFFFFFFFF;</code>.
     491             :  *
     492             :  * The multiplication first transforms 'a' into a number, then multiplies
     493             :  * by 1, and finally saves the result in 'a'. If 'a' was a string, it
     494             :  * applies a conversion which may be important when using 'a' later
     495             :  * (i.e. some functions you call may check whether 'a' is a number.)
     496             :  *
     497             :  * The concatenation in the last statement transforms the variable 'a'
     498             :  * to a string. You could also have used the <code>a.toString()</code>
     499             :  * function.
     500             :  *
     501             :  * When the unsafe math option is turned on, many of these operations
     502             :  * will get optimized anyway. In all the examples shown above, the
     503             :  * optimizer would simply remove the entire statement. The result
     504             :  * is different and thus it may not work right, this is why we offer
     505             :  * this option because at times you may want to turn off the pragma.
     506             :  *
     507             :  * In most cases, it is not recommended to use this option.
     508             :  */
     509             : 
     510             : 
     511             : /** \var Options::OPTION_max
     512             :  * \brief Gives the number of options defined.
     513             :  *
     514             :  * This is not an option. It is used to define arrays of options as all
     515             :  * options are numbered from 0 to OPTION_max - 1.
     516             :  */
     517             : 
     518             : 
     519             : 
     520             : 
     521             : /** \typedef Options::option_value_t
     522             :  * \brief The type used by options.
     523             :  *
     524             :  * Each option is an integer of this type. The type is at least 32 bits.
     525             :  *
     526             :  * Most options just use 0 (false/not set) or 1 (true/set). However, some
     527             :  * options may use other values. In most cases the value will be used as
     528             :  * a set of flags:
     529             :  *
     530             :  * \li OPTION_EXTENDED_STATEMENTS uses bit 1 to force programmers to use
     531             :  * blocks with 'if', 'while', 'for', etc.
     532             :  *
     533             :  * \li OPTION_EXTENDED_OPERATORS uses bit 1 to force programmers to use
     534             :  * the ':=' operator instead of the '=' operator.
     535             :  */
     536             : 
     537             : 
     538             : /** \typedef Options::pointer_t
     539             :  * \brief The smart pointer used when creating an Options object.
     540             :  *
     541             :  * All Options objects are created and saved in this type of pointer.
     542             :  * This allows us to ensure no memory leaks ensue and that the pointer
     543             :  * can be shared between all parties.
     544             :  */
     545             : 
     546             : 
     547             : /** \typedef Options::zoption_value_t
     548             :  * \brief A controlled version of the option values.
     549             :  *
     550             :  * When using the zoption_value_t typedef in your classes, you make
     551             :  * sure that the option value is initialized to the default value
     552             :  * which is zero (0).
     553             :  *
     554             :  * The Options class uses this type to create its vector of options.
     555             :  */
     556             : 
     557             : 
     558             : /** \var Options::f_options
     559             :  * \brief The array of options in the Options class.
     560             :  *
     561             :  * When creating an Options object, you get a set of options defined
     562             :  * in this f_options variable member.
     563             :  *
     564             :  * By default all the options are considered to be set to zero. So if
     565             :  * no option object was created, you may assume that all the values
     566             :  * are set to zero.
     567             :  *
     568             :  * If you then want to modify an option to a value other than zero (0)
     569             :  * then you must allocate an Options object and use the set_option()
     570             :  * function to set the value accordingly.
     571             :  */
     572             : 
     573             : 
     574             : 
     575             : 
     576             : /** \brief Initialize an options object.
     577             :  *
     578             :  * The default constructor initializes the options array to the maximum
     579             :  * number of options. The options are all set to the default, zero (0).
     580             :  *
     581             :  * To change the option value, use the set_option() function. At this
     582             :  * point pretty much all the options accept either 0 or 1 as their
     583             :  * value, although any number of than 0 is considered to represent "set".
     584             :  */
     585     5987138 : Options::Options()
     586     5987138 :     : f_options(static_cast<size_t>(option_t::OPTION_max))
     587             : {
     588     5987138 : }
     589             : 
     590             : 
     591             : /** \brief Set an option to the specified value.
     592             :  *
     593             :  * This function sets the option to the specified value.
     594             :  *
     595             :  * At this point, all options expect the value to be 0 or 1, although
     596             :  * the system does not enforce that at this point. Any value is thus
     597             :  * accepted.
     598             :  *
     599             :  * Options make use of an int64_t so any 64 bit values works.
     600             :  *
     601             :  * \param[in] option  The option to set.
     602             :  * \param[in] value  The new 64 bit value for this option.
     603             :  */
     604    14543572 : void Options::set_option(option_t option, option_value_t value)
     605             : {
     606    14543572 :     f_options[static_cast<size_t>(option)] = value;
     607    14543572 : }
     608             : 
     609             : 
     610             : /** \brief Retrieve the current value of an option.
     611             :  *
     612             :  * This function is used to retrieve the current value of an option.
     613             :  * At this point, all options are expected to be zero (0), the default,
     614             :  * or one (1). It is possible to set options to other values, though.
     615             :  *
     616             :  * \param[in] option  The option to retrieve.
     617             :  *
     618             :  * \return The current value of this option.
     619             :  */
     620    15060459 : Options::option_value_t Options::get_option(option_t option)
     621             : {
     622    15060459 :     return f_options[static_cast<size_t>(option)];
     623             : }
     624             : 
     625             : 
     626             : }
     627             : // namespace as2js
     628             : 
     629             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.10