Ejemplo n.º 1
0
void ShaderWithVariables::initProgram(const char* shadername)
{
    glGenVertexArrays(1, &m_vao);

    std::cout
        << "Shader ["
        << shadername
        << "] "
        ;

    std::string vs = shadername;
    std::string fs = shadername;
    vs += ".vert";
    fs += ".frag";

    m_program = makeShaderFromSource(vs.c_str(), fs.c_str());
    if (m_program == 0)
        return;

    std::cout << "  vars: ";
    const std::string vsrc = GetShaderSource(vs.c_str());
    findVariables(vsrc.c_str());
    const std::string fsrc = GetShaderSource(fs.c_str());
    findVariables(fsrc.c_str());

    std::cout
        << m_unis.size() << " unis, "
        << m_attrs.size() << " attrs."
        << std::endl;
}
Ejemplo n.º 2
0
XmlConfig::XmlConfigData::XmlConfigData(const char *file) :
    doc_(NULL), filename_(file) {

    namespace fs = boost::filesystem;
    std::string file_str;

#ifdef BOOST_FILESYSTEM_VERSION
    #if BOOST_FILESYSTEM_VERSION == 3
        fs::path path(file);
        file_str = path.native();
    #else
        fs::path path(file, fs::no_check);
        file_str = path.native_file_string();
    #endif
#else
    fs::path path(file, fs::no_check);
    file_str = path.native_file_string();
#endif

    if (!fs::exists(path)) {
        std::stringstream stream;
        stream << "can not read " << file_str;        
        throw std::runtime_error(stream.str());
    }
    
    doc_ = XmlDocHelper(xmlParseFile(file_str.c_str()));

    XmlUtils::throwUnless(NULL != doc_.get());
    if (NULL == xmlDocGetRootElement(doc_.get())) {
        throw std::logic_error("got empty config");
    }
    XmlUtils::throwUnless(xmlXIncludeProcess(doc_.get()) >= 0);
    findVariables(doc_);
}
Ejemplo n.º 3
0
void DwarfVariableFinder::findVariables(const DWARFDie &die) {

  for (auto child = die.getFirstChild(); child; child = child.getSibling()) {
    switch(child.getTag()) {
      case dwarf::DW_TAG_variable:
      case dwarf::DW_TAG_formal_parameter:
      case dwarf::DW_TAG_constant:
        handleVariable(child);
        break;
      default:
        if (child.hasChildren())
          findVariables(child);
    }
  }
}
Ejemplo n.º 4
0
DwarfVariableFinder::DwarfVariableFinder(const DWARFDie &die, raw_ostream &os) : OS(os) {
  if(!die.hasChildren()) {
    outs() << "No child \n\n";
    return;
  }

  for (auto child = die.getFirstChild(); child; child = child.getSibling()) {
    //Go over all the top level sub_programs
    if(child.isSubprogramDIE() || child.isSubroutineDIE()) {
      getInfo(child);

      //Look for variables among children of sub_program die
      if(!child.hasChildren()) {
        continue;
      }
      findVariables(child);
    }
  }
}
Ejemplo n.º 5
0
XmlConfig::XmlConfig(const char *file)
: doc_(nullptr), regex_("\\$\\{([A-Za-z][A-Za-z0-9\\-]*)\\}") {
	try {
		std::ifstream f(file);
		if (!f) {
			throw std::runtime_error(std::string("can not open ").append(file));
		}

		setFilename(file);

		doc_ = XmlDocHelper(xmlParseFile(file));
		XmlUtils::throwUnless(nullptr != doc_.get());
		if (nullptr == xmlDocGetRootElement(doc_.get())) {
			throw std::logic_error("got empty config");
		}
		XmlUtils::throwUnless(xmlXIncludeProcess(doc_.get()) >= 0);
		findVariables(doc_);
	} catch (const std::ios::failure &e) {
		throw std::runtime_error(std::string("can not read ").append(file));
	}
}