summaryrefslogtreecommitdiffstats
path: root/src/piklab-test/base/generator_check.h
blob: 2edb4c504aee55d3ec4fcab4d7aceef38419c744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/***************************************************************************
 *   Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org>                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/
#ifndef GPUTILS_GENERATOR_CHECK_H
#define GPUTILS_GENERATOR_CHECK_H

#include "device_test.h"
#include "common/cli/cli_log.h"
#include "common/global/pfile.h"
#include "coff/base/disassembler.h"
#include "common/global/process.h"
namespace Pic { class Memory; }

//----------------------------------------------------------------------------
class GeneratorCheckHelper
{
public:
  GeneratorCheckHelper();
  virtual ~GeneratorCheckHelper();
  virtual void initSupported() = 0;
  virtual bool init(const Device::Data &data) = 0;
  void cleanup();
  bool isSupported(const Device::Data &data) const { return _supported.contains(&data); }
  virtual PURL::FileType sourceFileType() const = 0;
  const Tool::SourceGenerator *generator() const { return _generator; }
  virtual SourceLine::List configEndLines() const = 0;

protected:
  TQValueList<const Device::Data *> _supported;
  Process::StringOutput *_cprocess, *_lprocess;
  Tool::SourceGenerator *_generator;

  friend class GeneratorCheck;
};

class GeneratorCheck : public DeviceTest
{
public:
  GeneratorCheck(GeneratorCheckHelper *helper);
  virtual ~GeneratorCheck();
  virtual bool skip(const Device::Data &data) const;
  virtual void runTest();
  virtual bool init(const Device::Data &data);
  virtual bool execute(const Device::Data &data);
  virtual void cleanup(const Device::Data &data);

protected:
  GeneratorCheckHelper *_helper;
  CLI::View  *_view;
  PURL::File *_fdest, *_fhex;
  Pic::Memory *_memory1;
  TQString _source;
};

//----------------------------------------------------------------------------
class ConfigGeneratorCheck : public GeneratorCheck
{
public:
  ConfigGeneratorCheck(GeneratorCheckHelper *helper) : GeneratorCheck(helper), _memory2(0) {}
  virtual bool init(const Device::Data &data);
  virtual bool execute(const Device::Data &data);
  virtual void cleanup(const Device::Data &data);

private:
  Pic::Memory *_memory2;
};

//----------------------------------------------------------------------------
class TemplateGeneratorCheck : public GeneratorCheck
{
public:
  TemplateGeneratorCheck(GeneratorCheckHelper *helper) : GeneratorCheck(helper) {}
  virtual bool init(const Device::Data &data);
};

//----------------------------------------------------------------------------
class GPUtilsGeneratorCheckHelper : public GeneratorCheckHelper
{
public:
  GPUtilsGeneratorCheckHelper();
  virtual void initSupported();
  virtual bool init(const Device::Data &data);
  virtual PURL::FileType sourceFileType() const { return PURL::AsmGPAsm; }
  virtual SourceLine::List configEndLines() const;
};

//----------------------------------------------------------------------------
class SDCCGeneratorCheckHelper : public GeneratorCheckHelper
{
public:
  SDCCGeneratorCheckHelper();
  virtual void initSupported();
  virtual bool init(const Device::Data &data);
  virtual PURL::FileType sourceFileType() const { return PURL::CSource; }
  virtual SourceLine::List configEndLines() const;
};
#endif