Esempio n. 1
0
    void mangle_variable(VarDeclaration *d, bool is_temp_arg_ref)
    {

        if (!(d->storage_class & (STCextern | STCgshared)))
        {
            d->error("ICE: C++ static non- __gshared non-extern variables not supported");
            assert(0);
        }

        Dsymbol *p = d->toParent();
        if (p && !p->isModule()) //for example: char Namespace1::beta[6] should be mangled as "_ZN10Namespace14betaE"
        {
            buf.writestring(global.params.isOSX ? "__ZN" : "_ZN");      // "__Z" for OSX, "_Z" for other
            prefix_name(p);
            source_name(d);
            buf.writeByte('E');
        }
        else //char beta[6] should mangle as "beta"
        {
            if (!is_temp_arg_ref)
            {
                if (global.params.isOSX)
                    buf.writeByte('_');
                buf.writestring(d->ident->toChars());
            }
            else
            {
                buf.writestring(global.params.isOSX ? "__Z" : "_Z");
                source_name(d);
            }
        }
    }
Esempio n. 2
0
File: cppmangle.c Progetto: yazd/dmd
void cpp_mangle_name(OutBuffer *buf, CppMangleState *cms, Dsymbol *s)
{
    Dsymbol *p = s->toParent();
    if (p && !p->isModule())
    {
        buf->writeByte('N');

        FuncDeclaration *fd = s->isFuncDeclaration();
        VarDeclaration *vd = s->isVarDeclaration();
        if (fd && fd->type->isConst())
        {
            buf->writeByte('K');
        }
        if (vd && !(vd->storage_class & (STCextern | STCgshared)))
        {
            s->error("C++ static non- __gshared non-extern variables not supported");
        }
        if (vd || fd)
        {
            prefix_name(buf, cms, p);
            source_name(buf, s);
        }
        else
        {
            assert(0);
        }
        buf->writeByte('E');
    }
    else
        source_name(buf, s);
}
Esempio n. 3
0
bool JABBuilder::createJAB(xmlNodePtr cur, const string& jname)
{
  string corr_tag("correlation");
  vector<FN*> jastrow;
  int ng = 0;
  ParticleSet* sourcePtcl=0;
  const xmlChar* s=xmlGetProp(cur,(const xmlChar*)"source");
  if (s != NULL)
  {
    map<string,ParticleSet*>::iterator pa_it(ptclPool.find((const char*)s));
    if (pa_it == ptclPool.end())
      return false;
    sourcePtcl = (*pa_it).second;
    ng=sourcePtcl->getSpeciesSet().getTotalNum();
    for (int i=0; i<ng; i++)
      jastrow.push_back(0);
  }
  cur = cur->xmlChildrenNode;
  while (cur != NULL)
  {
    string cname((const char*)(cur->name));
    if (cname == dtable_tag)
    {
      string source_name((const char*)(xmlGetProp(cur,(const xmlChar *)"source")));
      map<string,ParticleSet*>::iterator pa_it(ptclPool.find(source_name));
      if (pa_it == ptclPool.end())
        return false;
      sourcePtcl = (*pa_it).second;
      ng=sourcePtcl->getSpeciesSet().getTotalNum();
      XMLReport("Number of sources " << ng)
      for (int i=0; i<ng; i++)
        jastrow.push_back(0);
    }
    else
      if (cname == corr_tag)
Esempio n. 4
0
        static std::string make_default_source_name()
        {
            char buf[MAX_PATH];
            DWORD size = GetModuleFileNameA(NULL, buf, sizeof(buf) / sizeof(*buf));

            std::string source_name(buf, buf + size);
            if (source_name.empty())
            {
                // In case of error we provide artificial application name
                std::ostringstream strm;
                strm << "Boost.Log "
                    << static_cast< unsigned int >(BOOST_VERSION / 100000)
                    << "."
                    << static_cast< unsigned int >(BOOST_VERSION / 100 % 1000)
                    << "."
                    << static_cast< unsigned int >(BOOST_VERSION % 100);
                source_name = strm.str();
            }
            else
            {
                // Cut off the path and extension
                std::size_t backslash_pos = source_name.rfind('\\');
                if (backslash_pos == std::string::npos || backslash_pos >= source_name.size() - 1)
                    backslash_pos = 0;
                else
                    ++backslash_pos;
                std::size_t dot_pos = source_name.rfind('.');
                if (dot_pos == std::string::npos || dot_pos < backslash_pos)
                    dot_pos = source_name.size();
                source_name = source_name.substr(backslash_pos, dot_pos - backslash_pos);
            }

            return source_name;
        }
Esempio n. 5
0
    void prefix_name(Dsymbol *s)
    {
        if (!substitute(s))
        {
            store(s);
            Dsymbol *p = s->toParent();
            if (p && p->isTemplateInstance())
            {
                s = p;
                if (exist(p->isTemplateInstance()->tempdecl))
                {
                    p = NULL;
                }
                else
                {
                    p = p->toParent();
                }
            }

            if (p && !p->isModule())
            {
                prefix_name(p);
            }
            source_name(s);
        }
    }
Esempio n. 6
0
void cpp_mangle_name(OutBuffer *buf, CppMangleState *cms, Dsymbol *s)
{
    Dsymbol *p = s->toParent();
    if (p && !p->isModule())
    {
        buf->writeByte('N');

        FuncDeclaration *fd = s->isFuncDeclaration();
        if (fd->isConst())
            buf->writeByte('K');

        prefix_name(buf, cms, p);
        source_name(buf, s);

        buf->writeByte('E');
    }
    else
        source_name(buf, s);
}
Esempio n. 7
0
 void prefix_name(Dsymbol *s)
 {
     if (substitute(s))
         return;
     Dsymbol *p = s->toParent();
     if (p && !p->isModule())
         prefix_name(p);
     source_name(s);
     store(s);
 }
Esempio n. 8
0
  /** create Input Analytic function
   *
   * \xmlonly
   * <jastrow name="Jne" 
   *   type="Two-Body|One-Body|Polarization|Three-Body-Geminal"
   *   function="pade|pade2|no-cusp" 
   *   transform="no|yes" spin="no|yes" 
   *   source="ionic system">
   *   <grid/>
   *   <correlation speciesA="sourceSpecies" speciesB="targetSpecies" type="pade|pade2|no-cusp">
   *      <parameter name=" ">value<parameter>
   *   </correlation>
   * </jastrow>
   * \endxmlonly
   */
  bool NJABBuilder::putInFunc(xmlNodePtr cur) {

    string corr_tag("correlation");
    string jastfunction("pade");
    int	ng=1;

    const xmlChar *ftype = xmlGetProp(cur, (const xmlChar *)"function");
    if(ftype != NULL) jastfunction = (const char*) ftype;
    const xmlChar* s=xmlGetProp(cur,(const xmlChar*)"source");
    if(s != NULL) {
      map<string,ParticleSet*>::iterator pa_it(ptclPool.find((const char*)s));
      if(pa_it == ptclPool.end()) return false;
      sourcePtcl = (*pa_it).second;
      ng=sourcePtcl->getSpeciesSet().getTotalNum();
    }

    int ia=0, ib=0, iab=0;
    cur = cur->children;
    while(cur != NULL) {
      string cname((const char*)(cur->name));
      if(cname == "grid") {
        gridPtr=cur; //save the pointer
      } else if(cname == dtable_tag) {
      	string source_name((const char*)(xmlGetProp(cur,(const xmlChar *)"source")));
        map<string,ParticleSet*>::iterator pa_it(ptclPool.find(source_name));
        if(pa_it == ptclPool.end()) return false;
	sourcePtcl=(*pa_it).second;
	ng = sourcePtcl->getSpeciesSet().getTotalNum();
	XMLReport("Number of sources " << ng)
        InFunc.resize(ng,0);
      } else if(cname ==corr_tag) {
        if(sourcePtcl==0) return false;
        string jfunctype(jastfunction);
	string spA((const char*)(xmlGetProp(cur,(const xmlChar *)"speciesA")));
        ftype = xmlGetProp(cur, (const xmlChar *)"type");
        if(ftype) {
          jfunctype=(const char*)ftype;
        }

        ia = sourcePtcl->getSpeciesSet().findSpecies(spA);
	if(!(InFunc[ia])) {
          InFuncType *j1=createInFunc(jfunctype);
	  InFunc[ia]= j1;
	  app_log() <<"   Added Jastrow Correlation ("<<jfunctype 
            << ") between " <<spA<<" and "<<targetPtcl.getName() << endl;
	}
	InFunc[ia]->put(cur);
        InFunc[ia]->addOptimizables(targetPsi.VarList);
      }
      cur = cur->next;
    } // while cur
    
    return true;
  }
Esempio n. 9
0
void prefix_name(OutBuffer *buf, CppMangleState *cms, Dsymbol *s)
{
    if (!cms->substitute(buf, s))
    {
        Dsymbol *p = s->toParent();
        if (p && !p->isModule())
        {
            prefix_name(buf, cms, p);
        }
        source_name(buf, s);
    }
}
Esempio n. 10
0
    void mangle_function(FuncDeclaration *d)
    {
        /*
         * <mangled-name> ::= _Z <encoding>
         * <encoding> ::= <function name> <bare-function-type>
         *         ::= <data name>
         *         ::= <special-name>
         */
        TypeFunction *tf = (TypeFunction *)d->type;

        buf.writestring(global.params.isOSX ? "__Z" : "_Z");      // "__Z" for OSX, "_Z" for other
        Dsymbol *p = d->toParent();
        if (p && !p->isModule() && tf->linkage == LINKcpp)
        {
            buf.writeByte('N');
            if (d->type->isConst())
                buf.writeByte('K');
            prefix_name(p);
            if (d->isDtorDeclaration())
            {
                buf.writestring("D1");
            }
            else
            {
                source_name(d);
            }
            buf.writeByte('E');
        }
        else
        {
            source_name(d);
        }

        if (tf->linkage == LINKcpp) //Template args accept extern "C" symbols with special mangling
        {
            assert(tf->ty == Tfunction);
            argsCppMangle(tf->parameters, tf->varargs);
        }
    }
Esempio n. 11
0
    void cpp_mangle_name(Dsymbol *s)
    {
        Dsymbol *p = s->toParent();
        bool dont_write_prefix = false;
        if (p && p->isTemplateInstance())
        {
            s = p;
            if (exist(p->isTemplateInstance()->tempdecl))
                dont_write_prefix = true;
            p = p->toParent();
        }

        if (p && !p->isModule())
        {
            buf.writeByte('N');
            if (!dont_write_prefix)
                prefix_name(p);
            source_name(s);
            buf.writeByte('E');
        }
        else
            source_name(s);
    }
Esempio n. 12
0
void cpp_mangle_name(OutBuffer *buf, CppMangleState *cms, Dsymbol *s)
{
    Dsymbol *p = s->toParent();
    if (p && !p->isModule())
    {
        buf->writeByte('N');

        FuncDeclaration *fd = s->isFuncDeclaration();
        if (!fd)
        {
            s->error("C++ static variables not supported");
        }
        else if (fd->type->isConst())
            buf->writeByte('K');

        prefix_name(buf, cms, p);
        source_name(buf, s);

        buf->writeByte('E');
    }
    else
        source_name(buf, s);
}
Esempio n. 13
0
/**! Construct a data source
    A data source must provide a sample and an excludes list along
    with a uri. The default value for this is stdin. 
  
    \exception May propagate CErrnoException,s CURLFormatException,
        or CFatalException
*/
CDataSource* CFilterMain::constructDataSource()
{
  // Set up default source type
  std::string source_name("-");
  if (m_argsInfo->source_given) {
    source_name = std::string(m_argsInfo->source_arg);
  } 

  // Set up the sampling 
  std::vector<uint16_t> sample = constructSampleList();
  
  // Set up the excludes
  std::vector<uint16_t> exclude = constructExcludesList();
  
  CDataSource* source=0;
  return CDataSourceFactory().makeSource(source_name,sample,exclude);
}
Esempio n. 14
0
/*
 * SearchGbl -- look up a global symbol name
 */
static search_result LkupGblName( section_info *inf, imp_mod_handle cim,
                        imp_mod_handle im, lookup_item *li, void *d )
{
    gbl_link            *lnk;
    gbl_link            *lnk_array;
    gbl_info            *gbl;
    hash_link           lnk_off;
    int                 (*compare)(void const*,void const*,size_t);
    char                *gblname;
    size_t              gbllen;
    char                *nam = NULL;
    size_t              namlen = 0;
    char                *snam;
    size_t              snamlen;
    char                *mangled;
    size_t              mangle_len;
    unsigned            entry;
    info_block          *blk;
    int                 lkup_dtor;
    int                 lkup_full = 0;
    imp_sym_handle      *is;
    address             addr;
    search_result       sr;

    sr = SR_NONE;
    compare = li->case_sensitive ? memcmp : memicmp;

    lkup_dtor = (li->type == ST_DESTRUCTOR);
    /* only want to hash the source code portion of the name */
    switch( source_name( li->name.start, li->name.len, &snam, &snamlen ) ) {
    case __NOT_MANGLED:
        lkup_full = 0;
        nam = snam;
        namlen = snamlen;
        break;
    case __MANGLED_DTOR:
        lkup_dtor = 1;
        /* fall through */
    case __MANGLED_CTOR:
    case __MANGLED:
    case __MANGLED_INTERNAL:
        lkup_full = 1;
        nam = li->name.start;
        namlen = li->name.len;
        break;
    }
    for( blk = inf->gbl; blk != NULL; blk = blk->next ) {
        lnk_array = LINK( blk )->link;
        lnk_off = LINK( blk )->hash[ GblNameHash( snam, snamlen ) ];
        while( lnk_off != HL_END ) {
            lnk = MAKE_LP( lnk_array, lnk_off );
            gbl = lnk->gbl;
            if( lnk->dtor != lkup_dtor ) goto next_global;
            if( lkup_full ) {
                if( GBL_NAMELEN( gbl ) != namlen ) goto next_global;
            } else {
                if( lnk->src_len != namlen ) goto next_global;
            }
            if( im == IMH_NOMOD ) {
                if( GBL_KIND( gbl ) & GBL_KIND_STATIC &&
                    cim != GBL_MOD( gbl ) ) goto next_global;
            } else {
                if( im != GBL_MOD( gbl ) ) goto next_global;
            }
            mangled = GBL_NAME( gbl );
            gblname = mangled;
            if( !lkup_full ) gblname += lnk->src_off;
            if( compare( gblname, nam, namlen ) != 0 ) goto next_global;
            if( li->scope.start != NULL ) {
                mangle_len = GBL_NAMELEN( gbl );
                entry = 0;
                for( ;; ) {
                    if( !__scope_name( mangled, mangle_len, entry,
                             (const char **)&gblname, &gbllen ) ) goto next_global;
                    if( li->scope.len == gbllen &&
                        compare( li->scope.start, gblname, gbllen ) == 0 ) {
                        break;
                    }
                    ++entry;
                }
            }
            is = DCSymCreate( inf->ctl, d );
            is->im = GBL_MOD( gbl );
            MK_ADDR( addr, gbl->addr, inf->sect_id );
            /* need to see if there's a local symbol at the right
                    address and use that instead */
            if( cim == is->im ) {
                /* We've already checked the local symbols. It ain't there. */
                GblCreate( is, gbl );
            } else if( LookupLclAddr( inf->ctl, addr, is ) == SR_EXACT ) {
                SetGblLink( is, gbl );
            } else {
                GblCreate( is, gbl );
            }
            sr = SR_EXACT;
next_global:
            lnk_off = lnk->hash_off;
        }
    }
    return( sr );
}
Esempio n. 15
0
int main(int argc,char *argv[]) 
{
	//
	// Some initialization for the common library
	//
	SetApplicationParameters(
		"MemMap",
		TOOL_VERSION_MAJOR,
		TOOL_VERSION_MINOR,
		"{ApplicationName} - Version {ApplicationVersion} - This program is a part of the OSDK\r\n"
		"\r\n"
		"Author:\r\n"
		"  Pointier Mickael\r\n"
		"\r\n"
		"Switches:\r\n"
		" -f   Format\r\n"
		"       -f0 => XA (Oric) [default]\r\n"
		"       -f1 => Devpac (Atari ST)\r\n"
		"\r\n"
		);


	INPUT_FORMAT inputFormat=INPUT_FORMAT_ORIC_XA;		// 0=XA / 1=Devpac

	ArgumentParser cArgumentParser(argc,argv);

	while (cArgumentParser.ProcessNextArgument())
	{
		if (cArgumentParser.IsSwitch("-f"))
		{
			//format: [-f]
			//	0 => XA (Oric)
			// 	1 => Devpac (Atari)
			inputFormat=(INPUT_FORMAT)cArgumentParser.GetIntegerValue(INPUT_FORMAT_ORIC_XA);
		}
	}


    if (cArgumentParser.GetParameterCount()!=NB_ARG)
    {
		ShowError(0);
    }


	//
	// Copy last parameters
	//
	std::string	source_name(cArgumentParser.GetParameter(0));
	std::string	dest_name(cArgumentParser.GetParameter(1));
	std::string	project_name(cArgumentParser.GetParameter(2));
	std::string	css_name(cArgumentParser.GetParameter(3));

	/*
	printf("\n0=%s\n",source_name.c_str());
	printf("\n1=%s\n",dest_name.c_str());
	printf("\n2=%s\n",project_name.c_str());
	printf("\n3=%s\n",css_name.c_str());
	*/

	void* ptr_buffer_void;
	size_t size_buffer_src;

	//
	// Load the file
	//
	if (!LoadFile(source_name.c_str(),ptr_buffer_void,size_buffer_src))
	{
		printf("\nUnable to load file '%s'",source_name.c_str());
		printf("\n");
		exit(1);
	}

	unsigned char *ptr_buffer=(unsigned char*)ptr_buffer_void;

	//
	// Parse the file, and generate the list of values
	//
	std::map<std::string,Section>	Sections;

	switch (inputFormat)
	{
	case INPUT_FORMAT_ORIC_XA:
		{
			Section& section_zeropage=Sections["Zero"];
			section_zeropage.m_anchor_name	="Zero";
			section_zeropage.m_section_name	="Zero page";
			section_zeropage.m_adress_size	=2;
			section_zeropage.m_begin_adress	=0x0;
			section_zeropage.m_end_adress	=0xFF;

			Section& section_normal=Sections["Normal"];
			section_normal.m_anchor_name	="Normal";
			section_normal.m_section_name	="Normal memory";
			section_normal.m_adress_size	=4;
			section_normal.m_begin_adress	=0x400;
			section_normal.m_end_adress		=0xBFFF;

			Section& section_overlay=Sections["Overlay"];
			section_overlay.m_anchor_name	="Overlay";
			section_overlay.m_section_name	="Overlay memory";
			section_overlay.m_adress_size	=4;
			section_overlay.m_begin_adress	=0xC000;
			section_overlay.m_end_adress	=0xFFFF;
		}
		break;

	case INPUT_FORMAT_ATARI_DEVPAC:
		{
			Section& section_zeropage=Sections["Text"];
			section_zeropage.m_anchor_name	="Text";
			section_zeropage.m_section_name	="Section TEXT";
			section_zeropage.m_adress_size	=4;
			section_zeropage.m_begin_adress	=0x00;
			section_zeropage.m_end_adress	=0xFFFFFF;

			Section& section_normal=Sections["Data"];
			section_normal.m_anchor_name	="Data";
			section_normal.m_section_name	="Section DATA";
			section_normal.m_adress_size	=4;
			section_normal.m_begin_adress	=0x00;
			section_normal.m_end_adress		=0xFFFFFF;

			Section& section_overlay=Sections["Bss"];
			section_overlay.m_anchor_name	="Bss";
			section_overlay.m_section_name	="Section BSS";
			section_overlay.m_adress_size	=4;
			section_overlay.m_begin_adress	=0x00;
			section_overlay.m_end_adress	=0xFFFFFF;

			Section& section_rs=Sections["RS"];
			section_rs.m_anchor_name	="RS";
			section_rs.m_section_name	="RS offsets";
			section_rs.m_adress_size	=4;
			section_rs.m_begin_adress	=0x00;
			section_rs.m_end_adress	=0xFFFFFF;
		}
		break;
	}


	char *ptr_tok=strtok((char*)ptr_buffer," \r\n");
	while (ptr_tok)
	{
		// Address
		int value=strtol(ptr_tok,0,16);

		switch (inputFormat)
		{
		case INPUT_FORMAT_ORIC_XA:
			{
				ptr_tok=strtok(0," \r\n");
				// Name
				if (value<256)
				{
					// Zero page
					Sections["Zero"].GetMap()[value]=ptr_tok;
				}
				else
				if (value>=0xc000)
				{
					// Overlay memory
					Sections["Overlay"].GetMap()[value]=ptr_tok;
				}
				else
				{
					Sections["Normal"].GetMap()[value]=ptr_tok;
				}
			}
			break;
		case INPUT_FORMAT_ATARI_DEVPAC:
			{
				// ptr_tok:
				// A=Absolute (rs/offsets/computations)
				// R=Relocatable (addresses)
				// T=TEXT
				// D=DATA
				// B=BSS
				std::string section="Text";

				std::string token;
				do
				{
					ptr_tok=strtok(0," \r\n");
					token=ptr_tok;
					if (token=="A")			section="RS";
					else if (token=="B")	section="Bss";
					else if (token=="T")	section="Text";
					else if (token=="D")	section="Data";
				}
				while (token.size()==1);

				Sections[section].GetMap()[value]=token;
			}
		}
		ptr_tok=strtok(0," \r\n");
	}


	//
	// Generate the html file
	//
	std::string html(gHtmlHeader);

	StringReplace(html,"{PageTitle}"	,project_name);
	StringReplace(html,"{CssLink}"		,css_name);

	/*
	html+="<A href=\"#Zero\">Zero page</A><br>";
	html+="<A href=\"#Normal\">Normal memory</A><br>";
	html+="<A href=\"#Overlay\">Overlay memory</A><br>";
	*/

	html+="<table>\r\n";
	html+="<tr>\r\n";

	std::map<std::string,Section>::const_iterator it(Sections.begin());
	while (it!=Sections.end())
	{
		const Section& section=it->second;
		html+="<td valign=top>\r\n";
		section.Generate(html);
		html+="</td>\r\n";
		++it;
	}

	html+="</tr>\r\n";
	html+="</table>\r\n";

	html=html+gHtmlFooter;

	unsigned char *ptr_buffer_dst=new unsigned char[size_buffer_src+8];
	int size_buffer_dst=size_buffer_src/2;

	unsigned char *ptr_src=ptr_buffer;
	unsigned char *ptr_dst=ptr_buffer_dst;
	int i;
	for (i=0;i<size_buffer_dst;i++)
	{
		unsigned char b0=*ptr_src++;
		unsigned char b1=*ptr_src++;
		unsigned char b=(b1&0xF0)|(b0>>4);
		*ptr_dst++=b;
	}

	if (!SaveFile(dest_name.c_str(),html.c_str(),html.size()))
	{
		printf("\nUnable to save file '%s'",source_name.c_str());
		printf("\n");
		exit(1);
	}

	//
	// Make some cleaning
	//
	delete[] ptr_buffer;
	delete[] ptr_buffer_dst;

	return 0;
}