view anagram/vaclgui/openfile.cpp @ 15:f5acaf0c8a29

Don't cast through "volatile int". Causes a gcc warning nowadays. XXX: should put something else back here to frighten the optimizer
author David A. Holland
date Tue, 31 May 2022 01:00:55 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * openfile.cpp
 */

#include <icritsec.hpp>

#include "data.h"
#include "error.h"
#include "openfile.hpp"
#include "operations.h"
#include "vaclgui.hpp"

//#define INCLUDE_LOGGING
#include "log.h"


int analyzeThreadActive = 0;

/***********************************************************/
/* Overriding run() method for the file open thread        */
/* function class.  This function is called implicitly     */
/* when a thread to open a file is dispatched.             */
/***********************************************************/
void AnalyzeGrammarFn::run() {
  LOGSECTION("Analyzing input file");
  LOGV((int) &IThread::current());
  IThread::current().setVariable("Error Message", "");
  try {
    {
      ICritSec cookie;
      analyzeThreadActive = 1;
    }
    errorList.reset();
    analyzeGrammar(inputFile.text, 1 /* has GUI */);
    LOGS("Normal return from analyzeGrammar");
  }
  catch(IException &ie) {
    LOGSECTION("catch(IException &)");
    LOGV(ie.text());
    IThread::current().setVariable("Error Message", ie.text());
  }
  catch(Problem &p) {
    LOGSECTION("catch(Problem &)");
    LOGV(p.msg);
    IThread::current().setVariable("Error Message", p.msg);
  }
  ICritSec cookie;
  analyzeThreadActive = 0;
}

void BuildParserFn::run() {
  LOGSECTION("BuildParserFn::run");
  try {
    {
      ICritSec cookie;
      analyzeThreadActive = 1;
    }
    if (syntax_state != syntax_analyzed) {
      errorList.reset();
      analyzeGrammar(inputFile.text, 1 /* has GUI, will travel */);
    }
    buildParser();
    LOGS("returned from buildParser");
  }
  catch(IException &ie) {
    LOGV(ie.text());
    IThread::current().setVariable("Error Message", ie.text());
  }
  catch(Problem &p) {
    LOGV(p.msg);
    IThread::current().setVariable("Error Message", p.msg);
  }
  ICritSec cookie;
  analyzeThreadActive = 0;
  LOGS("Ready to exit");
}