コード例 #1
0
ファイル: standard.cpp プロジェクト: RicardoDeLosSantos/yacas
void InternalUse(LispEnvironment& aEnvironment, const std::string& aFileName)
{
    LispDefFile* def = aEnvironment.DefFiles().File(aFileName);
    if (!def->IsLoaded())
    {
        def->SetLoaded();

        for (const LispString* s: def->symbols)
            aEnvironment.UnProtect(s);

        InternalLoad(aEnvironment,aFileName);

        for (const LispString* s: def->symbols)
            aEnvironment.Protect(s);
    }
}
コード例 #2
0
ファイル: deffile.cpp プロジェクト: RicardoDeLosSantos/yacas
static void DoLoadDefFile(
    LispEnvironment& aEnvironment,
    LispInput* aInput,
    LispDefFile* def)
{
  LispLocalInput localInput(aEnvironment, aInput);

  const LispString* eof = aEnvironment.iEndOfFile->String();
  const LispString* end = aEnvironment.iListClose->String();

  bool endoffile = false;

  LispTokenizer tok;

  while (!endoffile)
  {
    // Read expression
    const LispString* token =
        tok.NextToken(*aEnvironment.CurrentInput(), aEnvironment.HashTable());

    // Check for end of file
    if (token == eof || token == end)
    {
      endoffile = true;
    }
    // Else evaluate
    else
    {
        LispMultiUserFunction* multiUser = aEnvironment.MultiUserFunction(token);

        if (multiUser->iFileToOpen != nullptr) {
            aEnvironment.CurrentOutput() << '[' << *token << "]\n";
            if (multiUser->iFileToOpen)
               throw LispErrDefFileAlreadyChosen();
        }

        multiUser->iFileToOpen = def;

        def->symbols.insert(token);

        aEnvironment.Protect(token);
    }
  }
}