Example #1
0
bool _ELC_::Project :: compileSources(_ELENA_::Compiler& compiler, _ELENA_::Parser& parser)
{
   bool debugMode = BoolSetting(_ELENA_::opDebugMode);

   _ELENA_::Unresolveds unresolveds(_ELENA_::Unresolved(), NULL);
   for (_ELENA_::SourceIterator it = _sources.start(); !it.Eof(); it++) {
      _ELENA_::Map<_ELENA_::ident_t, _ELENA_::ProjectSettings::VItem>* source = *it;

      // create module
      _ELENA_::ident_t name = source->get(ELC_NAMESPACE_KEY);
      _ELENA_::ModuleInfo moduleInfo = compiler.createModule(name, *this, debugMode);

      _ELENA_::ident_t target = source->get(ELC_TARGET_NAME);
      int type = !emptystr(target) ? _targets.get(target, ELC_TYPE_NAME, 1) : 1;
      if (type == 1) {
         // if it is a normal ELENA source file
         _ELENA_::ForwardIterator file_it = source->getIt(ELC_INCLUDE);
         while (!file_it.Eof()) {
            // compile a source file
            compile(*file_it, compiler, parser, moduleInfo, unresolveds);

            file_it = source->nextIt(ELC_INCLUDE, file_it);
         }
      }
      else if (type == 2) {
         // if it is a script file
         _ELENA_::ScriptParser scriptParser;

         // load options
         _ELENA_::Map<_ELENA_::ident_t, _ELENA_::TargetSettings::VItem>* targetInfo = _targets.get(target, (_ELENA_::Map<_ELENA_::ident_t, _ELENA_::TargetSettings::VItem>*)NULL);

         _ELENA_::TargetIterator option_it = targetInfo->getIt(ELC_OPTION);
         while (!option_it.Eof()) {
            if (!scriptParser.setOption(*option_it, StrSetting(_ELENA_::opProjectPath))) {
               raiseError(errInvalidTargetOption, *option_it);
            }

            option_it = targetInfo->nextIt(ELC_OPTION, option_it);
         }

         // compile script files
         _ELENA_::ForwardIterator file_it = source->getIt(ELC_INCLUDE);
         while (!file_it.Eof()) {
            compile(*file_it, compiler, scriptParser, moduleInfo, unresolveds);

            file_it = source->nextIt(ELC_INCLUDE, file_it);
         }
      }

      saveModule(moduleInfo.codeModule, "nl");

      if (moduleInfo.debugModule)
         saveModule(moduleInfo.debugModule, "dnl");
   }

   // validate the unresolved forward refereces if unresolved reference warning is enabled
   compiler.validateUnresolved(unresolveds, *this);

   return !HasWarnings();
}
Example #2
0
_ELENA_::_JITCompiler* _ELC_::Project :: createJITCompiler()
{
   return new _ELENA_::x86JITCompiler(BoolSetting(_ELENA_::opDebugMode));
}