Ignore:
Timestamp:
Jan 30, 2015, 1:27:51 AM (10 years ago)
Author:
bird
Message:

Started on a make expression and string expansion 'compiler'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/function.c

    r2758 r2765  
    4343#  include <limits.h>
    4444# endif
     45#endif
     46#ifdef CONFIG_WITH_COMPILER
     47# include "kmk_cc_exec.h"
    4548#endif
    4649#include <assert.h> /* bird */
     
    20432046      size_t off;
    20442047      const struct floc *reading_file_saved = reading_file;
    2045 #ifdef CONFIG_WITH_MAKE_STATS
     2048# ifdef CONFIG_WITH_MAKE_STATS
    20462049      unsigned long long uStartTick = CURRENT_CLOCK_TICK();
    2047       MAKE_STATS_2(v->cEvalVals++);
    2048 #endif
    2049 
    2050       /* Make a copy of the value to the variable buffer since
    2051          eval_buffer will make changes to its input. */
    2052 
    2053       off = o - variable_buffer;
    2054       variable_buffer_output (o, v->value, v->value_length + 1);
    2055       o = variable_buffer + off;
    2056 
    2057       /* Eval the value.  Pop the current variable buffer setting so that the
    2058          eval'd code can use its own without conflicting. (really necessary?)  */
    2059 
    2060       install_variable_buffer (&buf, &len);
     2050#  ifndef CONFIG_WITH_COMPILER
     2051      MAKE_STATS_2(v->evalval_count++);
     2052#  endif
     2053# endif
     2054
    20612055      var_ctx = !strcmp (funcname, "evalvalctx");
    20622056      if (var_ctx)
     
    20652059        reading_file = &v->fileinfo;
    20662060
    2067       assert (!o[v->value_length]);
    2068       eval_buffer (o, o + v->value_length);
     2061# ifdef CONFIG_WITH_COMPILER
     2062      /* If this variable has been evaluated more than a few times, it make
     2063         sense to compile it to speed up the processing. */
     2064
     2065      v->evalval_count++;
     2066      if (   v->evalprog
     2067          || (v->evalval_count == 3 && kmk_cc_compile_variable_for_eval (v)))
     2068        {
     2069          install_variable_buffer (&buf, &len); /* Really necessary? */
     2070          kmk_exec_evalval (v);
     2071          restore_variable_buffer (buf, len);
     2072        }
     2073      else
     2074# endif
     2075      {
     2076        /* Make a copy of the value to the variable buffer first since
     2077           eval_buffer will make changes to its input. */
     2078
     2079        off = o - variable_buffer;
     2080        variable_buffer_output (o, v->value, v->value_length + 1);
     2081        o = variable_buffer + off;
     2082        assert (!o[v->value_length]);
     2083
     2084        install_variable_buffer (&buf, &len); /* Really necessary? */
     2085        eval_buffer (o, o + v->value_length);
     2086        restore_variable_buffer (buf, len);
     2087      }
    20692088
    20702089      reading_file = reading_file_saved;
    20712090      if (var_ctx)
    20722091        pop_variable_scope ();
    2073       restore_variable_buffer (buf, len);
    20742092
    20752093      MAKE_STATS_2(v->cTicksEvalVal += CURRENT_CLOCK_TICK() - uStartTick);
     
    21422160              v->value_length = dst - v->value;
    21432161            }
     2162
     2163# ifdef CONFIG_WITH_COMPILER
     2164          /* Compile the variable for evalval, evalctx and expansion. */
     2165
     2166          if (!v->evalprog)
     2167            kmk_cc_compile_variable_for_eval (v);
     2168          if (!v->expandprog)
     2169            kmk_cc_compile_variable_for_expand (v);
     2170# endif
    21442171        }
    21452172      else if (v)
Note: See TracChangeset for help on using the changeset viewer.