Exemplo n.º 1
0
wxString Token::DisplayName() const
{
    wxString result;
    if      (m_TokenKind == tkClass)
        return result << _T("class ")     << m_Name << m_BaseArgs << _T(" {...}");
    else if (m_TokenKind == tkNamespace)
        return result << _T("namespace ") << m_Name << _T(" {...}");
    else if (m_TokenKind == tkEnum)
        return result << _T("enum ")      << m_Name << _T(" {...}");
    else if (m_TokenKind == tkTypedef)
    {
        result << _T("typedef");

        if (!m_FullType.IsEmpty())
            result << _T(" ") << m_FullType;

        // we support 2 cases of typedef'd function pointers, and in each case the type is stored
        // as below:
        // typedef void (*dMessageFunction)(int errnum, const char *msg, va_list ap);
        // --> type is stored as: (*)
        // typedef void (MyClass::*Function)(int);
        // --> type is stored as: (MyClass::*)
        // so, ensure we really have ')' as the last char.
        if (result.Find('*', true) != wxNOT_FOUND && result.Last() == ')')
        {
            result.RemoveLast();
            return result << m_Name << _T(")") <<  GetFormattedArgs();
        }

        if (!m_TemplateArgument.IsEmpty())
            result << m_TemplateArgument;

        return result << _T(" ") << m_Name;
    }
    else if (m_TokenKind == tkMacroDef)
    {
        result << _T("#define ") << m_Name << GetFormattedArgs();
        if (!m_FullType.IsEmpty())
            result << _T(" ") << m_FullType;

        return result;
    }

    // else
    if (!m_FullType.IsEmpty())
        result << m_FullType << m_TemplateArgument << _T(" ");

    if (m_TokenKind == tkEnumerator)
        return result << GetNamespace() << m_Name << _T("=") << GetFormattedArgs();

    return result << GetNamespace() << m_Name << GetStrippedArgs();
}
Exemplo n.º 2
0
 XMLNode XMLNode::NewChild(const XMLNode& node, int n, bool global_order) {
   if (node_ == NULL)
     return XMLNode();
   if (node.node_ == NULL)
     return XMLNode();
   if (node_->type != XML_ELEMENT_NODE)
     return XMLNode();
   // TODO: Add new attribute if 'node' is attribute
   if (node.node_->type != XML_ELEMENT_NODE)
     return XMLNode();
   xmlNodePtr new_node = xmlDocCopyNode(node.node_, node_->doc, 1);
   if (new_node == NULL)
     return XMLNode();
   if (n < 0)
     return XMLNode(xmlAddChild(node_, new_node));
   std::string name;
   xmlNsPtr ns = GetNamespace(new_node);
   if (ns != NULL) {
     if (ns->prefix != NULL)
       name = (char*)ns->prefix;
     name += ":";
   }
   if (new_node->name)
     name += (char*)(new_node->name);
   XMLNode old_node = global_order ? Child(n) : operator[](name)[n];
   if (!old_node)
     // TODO: find last old_node
     return XMLNode(xmlAddChild(node_, new_node));
   if (old_node)
     return XMLNode(xmlAddPrevSibling(old_node.node_, new_node));
   return XMLNode(xmlAddChild(node_, new_node));
 }
Exemplo n.º 3
0
Namespace *SKS::GetNamespace(Position &pos, bool noName)
{
	Namespace *name = new Namespace();
	if(!noName)
		name->SetName(GetName(pos));

	while(true)
	{
		if(islineEndOfFile(pos))
		{
			break;
		}
		SkipComment(pos);
		if(isLineNamespaceEnd(pos))
		{
			ExitNamespace(pos);
			break;
		}
		else if(isLineNamespace(pos))
		{
			name->AddNamespace(GetNamespace(pos));
		}
		else if(isLineKeyValue(pos))
		{
			name->AddKeyValue(GetKeyValue(pos));
		}
		else
			break;
	}
	return name;
}
Exemplo n.º 4
0
/*RemoveAttribute - remove attribute from element
attname - name of attribute to remove
returns False on error
*/
Bool CXMLElement::RemoveAttribute(char *attname)
{
	if (!isinited())
		return False;

	// OK-2009-01-06: [[Bug 7586]] - Remove the namespace if that is the name of the attribute.
	// Not sure how reliable this is, it seems to work ok. The revXMLRemoveAttribute is not currently
	// documented.
	if (strcasecmp(attname, "xmlns") == 0)
	{
		xmlNsPtr t_namespace;
		t_namespace = NULL;
		GetNamespace(t_namespace);
		if (t_namespace != NULL)
			xmlFreeNs(t_namespace);

		element -> ns = NULL;
		element -> nsDef = NULL;
		return True;
	}
	else
	{
		int res = xmlUnsetProp (element, (xmlChar *)attname);
		return res == 0;
	}
}
Exemplo n.º 5
0
int litlist(ENODE *node)
{
	struct slit *lp;
	ENODE *ep;

	lp = strtab;
	while (lp) {
		if (lp->isString)
			continue;
		ep = (ENODE *)lp->str;
		if (node->IsEqual(node, ep)) {
			return (lp->label);
		}
		lp = lp->next;
	}
	lp = (struct slit *)allocx(sizeof(struct slit));
	lp->label = nextlabel++;
	lp->str = (char *)node;
	lp->nmspace = my_strdup(GetNamespace());
	if (strtab == nullptr) {
		strtab = lp;
		strtab->tail = lp;
	}
	else {
		strtab->tail->next = lp;
		strtab->tail = lp;
	}
	lp->isString = false;
	lp->pass = pass;
	return (lp->label);
}
Exemplo n.º 6
0
//
// Output all code and labels in the peep list.
//
void PeepList::flush()
{
	static bool first = true;
	txtoStream* oofs;
	OCODE *ip;

/*
	if (pass == 2) {
		if (first) {
			compiler.storeTables();
			first = false;
		}
		oofs = new txtoStream();
		oofs->open(irfile, std::ios::out | std::ios::app);
		currentFn->pl.storeHex(*oofs);
		oofs->close();
		delete oofs;
	}
*/
	for (ip = head; ip; ip = ip->fwd)
	{
		if (ip->opcode == op_label)
			put_label((int)ip->oper1, "", GetNamespace(), 'C');
		else
			ip->store(ofs);
	}
}
Exemplo n.º 7
0
 std::string XMLNode::Namespace(void) const {
   if (!node_)
     return "";
   xmlNsPtr ns = GetNamespace(node_);
   if (!ns)
     return "";
   if (!(ns->href))
     return "";
   return (const char*)(ns->href);
 }
Exemplo n.º 8
0
wxString Token::DisplayName() const
{
//    wxString result(_T(""));
//    wxString parentname = GetParentName();
//    if (!parentname.IsEmpty())
//        result << parentname << _T("::");
    wxString result = GetNamespace();
    result << m_Name << m_Args;
    if (!m_Type.IsEmpty())
        result << _T(" : ") << m_Type;
    return result;
}
Exemplo n.º 9
0
/*
 *      output all code and labels in the peep list.
 */
void flush_peep()
{
	if (opt_nopeep==FALSE)
		opt_peep();         /* do the peephole optimizations */
  while( peep_head != NULL )
  {
		if( peep_head->opcode == op_label )
			put_label((int64_t)peep_head->oper1,"",GetNamespace(),'C');
		else
			put_ocode(peep_head);
		peep_head = peep_head->fwd;
  }
}
Exemplo n.º 10
0
cc_string Token::DisplayName() const
{
    cc_string result;
    if      (m_TokenKind == tkClass)
        return result << cc_text("class ")     << m_Name << m_RealArgs << cc_text(" {...}");
    else if (m_TokenKind == tkNamespace)
        return result << cc_text("namespace ") << m_Name << cc_text(" {...}");
    else if (m_TokenKind == tkEnum)
        return result << cc_text("enum ")      << m_Name << cc_text(" {...}");
    else if (m_TokenKind == tkTypedef)
    {
        result << cc_text("typedef");

        if (!m_Type.empty())
            result << cc_text(" ") << m_Type;

                if (result.rfind('*') != cc_string::npos)
        {
            result.erase(result.end()-1,result.end());
            return result << m_Name << cc_text(")") <<  m_Args;
        }
        return result << cc_text(" ") << m_Name;
    }
    else if (m_TokenKind == tkMacroDefine)
    {
        result << cc_text("#define ") << m_Name << m_Args;
        if (!m_Type.empty())
            return result << cc_text(" ") << m_Type;
    }

    // else
    if (!m_Type.empty())
        result << m_Type << cc_text(" ");

	if (m_TokenKind == tkEnumerator)
                return 	result << GetNamespace() << m_Name << cc_text("=") << m_Args;

    return result << GetNamespace() << m_Name << m_Args;
}
Exemplo n.º 11
0
void GenerateLabelReference(int n, int64_t offset)
{ 
	char buf[200];

	if( gentype == longgen && outcol < 58) {
		if (offset==0)
			sprintf_s(buf, sizeof(buf), ",%s_%d", GetNamespace(), n);
		else
			sprintf_s(buf, sizeof(buf), ",%s_%d+%lld", GetNamespace(), n, offset);
		ofs.printf(buf);
        outcol += 6;
    }
    else {
        nl();
				if (offset == 0)
					sprintf_s(buf, sizeof(buf), "\tdw\t%s_%d", GetNamespace(), n);
				else
					sprintf_s(buf, sizeof(buf), "\tdw\t%s_%d+%lld", GetNamespace(), n, offset);
				ofs.printf(buf);
        outcol = 22;
        gentype = longgen;
    }
}
Exemplo n.º 12
0
void doinit(SYM *sp)
{
	char lbl[200];

	lbl[0] = 0;
	if (sp->storage_class == sc_thread) {
		seg(tlsseg);
		nl();
	}
	else if (sp->storage_class == sc_static || lastst==assign) {
		seg(dataseg);          /* initialize into data segment */
		nl();                   /* start a new line in object */
	}
	else {
		seg(bssseg);            /* initialize into data segment */
		nl();                   /* start a new line in object */
	}
	if(sp->storage_class == sc_static || sp->storage_class == sc_thread) {
		put_label(sp->value.i, sp->name, GetNamespace(), 'D');
	}
	else {
		if (sp->storage_class == sc_global) {
			strcpy(lbl, "public ");
			if (curseg==dataseg)
				strcat(lbl, "data ");
			else if (curseg==bssseg)
				strcat(lbl, "bss ");
			else if (curseg==tlsseg)
				strcat(lbl, "tls ");
		}
		strcat(lbl, sp->name);
		gen_strlab(lbl);
	}
	if( lastst != assign) {
		genstorage(sp->tp->size);
	}
	else {
		NextToken();
		InitializeType(sp->tp);
	}
    endinit();
	if (sp->storage_class == sc_global)
		fprintf(output,"\nendpublic\n");
}
Exemplo n.º 13
0
Namespace *SKS::GetNamespaceFromFile(const char *fileName)
{
	// Creates a stream to read the file from
	fstream sksFile(fileName, ios::in);

	// Breaks of the file couldn't be open
	if(sksFile.fail())
		return NULL;

	// Seek end of file
	sksFile.seekg(0, ios::end);

	// saves length of file
	m_lengthOfFile = (unsigned int)sksFile.tellg();

	// Seeks the beginning of the file
	sksFile.seekg(0, ios::beg);

	// Allocates memory for the file in memory
	m_fileContents = new char [m_lengthOfFile];

	// Reads the entire file
	sksFile.read(m_fileContents, m_lengthOfFile);

	sksFile.close();

	// Currents position in the file
	Position curPosition;

	// Creates the namespace that gets filled with the info from the file
	Namespace *topLevel;

	// Adds sets the namespace without a name
	topLevel = GetNamespace(curPosition, true);

	// Sorts the names for a faster search
	topLevel->SortIndexes();

	// Deletes the character buffer
	delete []m_fileContents;
	m_fileContents = NULL;

	return topLevel;
}
Exemplo n.º 14
0
/*
 *      make s a string literal and return it's label number.
 */
int stringlit(char *s)
{      
	struct slit *lp;

	lp = (struct slit *)allocx(sizeof(struct slit));
	lp->label = nextlabel++;
	lp->str = my_strdup(s);
	lp->nmspace = my_strdup(GetNamespace());
	if (strtab == nullptr) {
		strtab = lp;
		strtab->tail = lp;
	}
	else {
		strtab->tail->next = lp;
		strtab->tail = lp;
	}
	lp->isString = true;
	lp->pass = pass;
	return (lp->label);
}
Exemplo n.º 15
0
int caselit(struct scase *cases, int64_t num)
{
	struct c**t *lp;

	lp = casetab;
	while (lp) {
		if (memcmp(lp->cases, cases, num * sizeof(struct scase)) == 0)
			return (lp->label);
		lp = lp->next;
	}
	lp = (struct c**t *)allocx(sizeof(struct c**t));
	lp->label = nextlabel++;
	lp->nmspace = my_strdup(GetNamespace());
	lp->cases = (struct scase *)allocx(sizeof(struct scase)*(int)num);
	lp->num = (int)num;
	lp->pass = pass;
	memcpy(lp->cases, cases, (int)num * sizeof(struct scase));
	lp->next = casetab;
	casetab = lp;
	return lp->label;
}
Exemplo n.º 16
0
int quadlit(Float128 *f128)
{
	Float128 *lp;
	lp = quadtab;
	// First search for the same literal constant and it's label if found.
	while(lp) {
		if (Float128::IsEqual(f128,Float128::Zero())) {
			if (Float128::IsEqualNZ(lp,f128))
				return (lp->label);
		}
		else if (Float128::IsEqual(lp,f128))
			return (lp->label);
		lp = lp->next;
	}
	lp = (Float128 *)allocx(sizeof(Float128));
	lp->label = nextlabel++;
	Float128::Assign(lp,f128);
	lp->nmspace = my_strdup(GetNamespace());
	lp->next = quadtab;
	quadtab = lp;
	return (lp->label);
}
Exemplo n.º 17
0
/*SetAttribute - set attribute value in element
attname-attribute name
tdata - new value
returns False on error
*/
Bool CXMLElement::SetAttribute(char *attname,char *tdata)
{
	if (!isinited())
		return False;

	// OK-2009-01-06: [[Bug 7586]] - When setting attributes, check to see if the user is trying to set the namespace.
	// If they are, then either create a namespace, or modify the existing one. Note that this doesn't support multiple
	// namespaces, not sure if this is a problem or not.
	xmlAttrPtr  tatt;
	if (strcasecmp(attname, "xmlns") == 0)
	{
		xmlNs *t_namespace;
		t_namespace = NULL;
		GetNamespace(t_namespace);
		if (t_namespace != NULL && t_namespace -> href != NULL)
		{
			// Free the old href buffer, and replace it with a new one
			xmlFree((xmlChar* )t_namespace -> href);
			t_namespace -> href = xmlStrdup((xmlChar *)tdata);

			// Replace the existing namespace with the modified one
			xmlSetNs(element, t_namespace);
		}
		else
		{
			// No namespace exists, so we just create one.
			t_namespace = xmlNewNs(element, (xmlChar *)tdata, NULL);
		}

		return True;
	}
	else
	{
		tatt = xmlSetProp(element, (xmlChar *)attname, (xmlChar *)tdata);
		return tatt != NULL;
	}
}
Exemplo n.º 18
0
/*GetAttribute - returns value of specified attribute
attname - name of attribute to look for
isbuffered - if true returns copy of attribute value (must be freed by caller).
returns NULL if specified attribute not found
*/
char *CXMLElement::GetAttributeValue(char *attname, Bool isbuffered)
{
	if (!isinited()) 
		return NULL;

	// OK-2009-01-05: [[Bug 7586]] - Some elements may have a "namespace". This is not regarded by libXML
	// as one of the elements' attributes, but is stored separately. If the required attribute is called 
	// "xmlns", then we retreive the namespace instead of using GetAttributeValue.
	if (strcasecmp(attname, "xmlns") == 0)
	{
		xmlNs *t_namespace;
		t_namespace = NULL;
		GetNamespace(t_namespace);

		if (t_namespace != NULL && t_namespace -> href != NULL)
		{
			return strdup((char *)t_namespace -> href);
		}
	}

	if (isbuffered)
	{
		CXMLAttribute tattribute;
		if (GetFirstAttribute(&tattribute))
		{
			int attributecount = 1;
			do 
			{
				if (!attname || util_strnicmp(tattribute.GetName(), attname, strlen(attname)) == 0)
					return tattribute.GetContent();
			} while (tattribute.GoNext());
		}
	}
	else
		return (char *)xmlGetProp(element, (xmlChar *)attname);
	return NULL;
}
// Check for any problems with WeakPtrFactory class members. This currently
// only checks that any WeakPtrFactory<T> member of T appears as the last
// data member in T. We could consider checking for bad uses of
// WeakPtrFactory to refer to other data members, but that would require
// looking at the initializer list in constructors to see what the factory
// points to.
// Note, if we later add other unrelated checks of data members, we should
// consider collapsing them in to one loop to avoid iterating over the data
// members more than once.
void FindBadConstructsConsumer::CheckWeakPtrFactoryMembers(
    SourceLocation record_location,
    CXXRecordDecl* record) {
  // Skip anonymous structs.
  if (record->getIdentifier() == NULL)
    return;

  // Iterate through members of the class.
  RecordDecl::field_iterator iter(record->field_begin()),
      the_end(record->field_end());
  SourceLocation weak_ptr_factory_location;  // Invalid initially.
  for (; iter != the_end; ++iter) {
    // If we enter the loop but have already seen a matching WeakPtrFactory,
    // it means there is at least one member after the factory.
    if (weak_ptr_factory_location.isValid()) {
      diagnostic().Report(weak_ptr_factory_location,
                          diag_weak_ptr_factory_order_);
    }
    const TemplateSpecializationType* template_spec_type =
        iter->getType().getTypePtr()->getAs<TemplateSpecializationType>();
    if (template_spec_type) {
      const TemplateDecl* template_decl =
          template_spec_type->getTemplateName().getAsTemplateDecl();
      if (template_decl && template_spec_type->getNumArgs() >= 1) {
        if (template_decl->getNameAsString().compare("WeakPtrFactory") == 0 &&
            GetNamespace(template_decl) == "base") {
          const TemplateArgument& arg = template_spec_type->getArg(0);
          if (arg.getAsType().getTypePtr()->getAsCXXRecordDecl() ==
              record->getTypeForDecl()->getAsCXXRecordDecl()) {
            weak_ptr_factory_location = iter->getLocation();
          }
        }
      }
    }
  }
}
Exemplo n.º 20
0
void ParseFunctionBody(SYM *sp)
{    
	char lbl[200];

	needpunc(begin);
    ParseAutoDeclarations();
	cseg();
	if (sp->storage_class == sc_static)
	{
		strcpy(lbl,GetNamespace());
		strcat(lbl,"_");
		strcat(lbl,sp->name);
		gen_strlab(lbl);
	}
	//	put_label((unsigned int) sp->value.i);
	else
		gen_strlab(sp->name);
	currentFn = sp;
	currentFn->IsLeaf = TRUE;
	currentFn->DoesThrow = FALSE;
    GenerateFunction(sp, ParseCompoundStatement());
//	if (optimize)
		flush_peep();
}
bool FindBadConstructsConsumer::InTestingNamespace(const Decl* record) {
  return GetNamespace(record).find("testing") != std::string::npos;
}
Exemplo n.º 22
0
void doinit(SYM *sp)
{
	char lbl[200];
  int algn;
  enum e_sg oseg;

  oseg = noseg;
	lbl[0] = 0;
	// Initialize constants into read-only data segment. Constants may be placed
	// in ROM along with code.
	if (sp->isConst) {
    oseg = rodataseg;
  }
	if (sp->storage_class == sc_thread) {
        if (sp->tp->type==bt_struct || sp->tp->type==bt_union)
           algn = imax(sp->tp->alignment,2);
        else if (sp->tp->type==bt_pointer && sp->tp->val_flag)
           algn = imax(sp->tp->GetBtp()->alignment,2);
        else
            algn = 2;
		seg(oseg==noseg ? tlsseg : oseg,algn);
		nl();
	}
	else if (sp->storage_class == sc_static || lastst==assign) {
        if (sp->tp->type==bt_struct || sp->tp->type==bt_union)
           algn = imax(sp->tp->alignment,2);
        else if (sp->tp->type==bt_pointer && sp->tp->val_flag)
           algn = imax(sp->tp->GetBtp()->alignment,2);
        else
            algn = 2;
		seg(oseg==noseg ? dataseg : oseg,algn);          /* initialize into data segment */
		nl();                   /* start a new line in object */
	}
	else {
        if (sp->tp->type==bt_struct || sp->tp->type==bt_union)
           algn = imax(sp->tp->alignment,2);
        else if (sp->tp->type==bt_pointer && sp->tp->val_flag)
           algn = imax(sp->tp->GetBtp()->alignment,2);
        else
            algn = 2;
		seg(oseg==noseg ? bssseg : oseg,algn);            /* initialize into data segment */
		nl();                   /* start a new line in object */
	}
	if(sp->storage_class == sc_static || sp->storage_class == sc_thread) {
		sp->realname = my_strdup(put_label(sp->value.i, (char *)sp->name->c_str(), GetNamespace(), 'D'));
	}
	else {
		if (sp->storage_class == sc_global) {
			strcpy_s(lbl, sizeof(lbl), "public ");
			if (curseg==dataseg)
				strcat_s(lbl, sizeof(lbl), "data ");
			else if (curseg==bssseg)
				strcat_s(lbl, sizeof(lbl), "bss ");
			else if (curseg==tlsseg)
				strcat_s(lbl, sizeof(lbl), "tls ");
		}
		strcat_s(lbl, sizeof(lbl), sp->name->c_str());
		gen_strlab(lbl);
	}
	if (lastst == kw_firstcall) {
        GenerateByte(1);
        return;
    }
	else if( lastst != assign) {
		genstorage(sp->tp->size);
	}
	else {
		NextToken();
		InitializeType(sp->tp);
	}
    endinit();
	if (sp->storage_class == sc_global)
		ofs.printf("\nendpublic\n");
}
Exemplo n.º 23
0
void GenerateReference(SYM *sp,int64_t offset)
{
	char    sign;
    if( offset < 0) {
        sign = '-';
        offset = -offset;
    }
    else
        sign = '+';
    if( gentype == longgen && outcol < 55 - (int)sp->name->length()) {
        if( sp->storage_class == sc_static) {
			ofs.printf(",");
			ofs.printf(GetNamespace());
			ofs.printf("_%lld", sp->value.i);
			ofs.putch(sign);
			ofs.printf("%lld", offset);
//                fprintf(output,",%s_%ld%c%d",GetNamespace(),sp->value.i,sign,offset);
		}
        else if( sp->storage_class == sc_thread) {
			ofs.printf(",");
			ofs.printf(GetNamespace());
			ofs.printf("_%lld", sp->value.i);
			ofs.putch(sign);
			ofs.printf("%lld", offset);
//                fprintf(output,",%s_%ld%c%d",GetNamespace(),sp->value.i,sign,offset);
		}
		else {
			if (offset==0) {
                ofs.printf(",%s",(char *)sp->name->c_str());
			}
			else {
                ofs.printf(",%s",(char *)sp->name->c_str());
				ofs.putch(sign);
				ofs.printf("%lld",offset);
			}
		}
        outcol += (11 + sp->name->length());
    }
    else {
        nl();
        if(sp->storage_class == sc_static) {
			ofs.printf("\tdw\t%s",GetNamespace());
			ofs.printf("_%lld",sp->value.i);
			ofs.putch(sign);
			ofs.printf("%lld",offset);
//            fprintf(output,"\tdw\t%s_%ld%c%d",GetNamespace(),sp->value.i,sign,offset);
		}
        else if(sp->storage_class == sc_thread) {
//            fprintf(output,"\tdw\t%s_%ld%c%d",GetNamespace(),sp->value.i,sign,offset);
			ofs.printf("\tdw\t%s",GetNamespace());
			ofs.printf("_%lld",sp->value.i);
			ofs.putch(sign);
			ofs.printf("%lld",offset);
		}
		else {
			if (offset==0) {
				ofs.printf("\tdw\t%s",(char *)sp->name->c_str());
			}
			else {
				ofs.printf("\tdw\t%s",(char *)sp->name->c_str());
				ofs.putch(sign);
				ofs.printf("%lld", offset);
//				fprintf(output,"\tdw\t%s%c%d",sp->name,sign,offset);
			}
		}
        outcol = 26 + sp->name->length();
        gentype = longgen;
    }
}
Exemplo n.º 24
0
void doinit(SYM *sp)
{
	static bool first = true;
	char lbl[200];
  int algn;
  enum e_sg oseg;
  char buf[500];
  std::streampos endpoint;
	TYP *tp;

  hasPointer = false;
  if (first) {
	  firstPrim = true;
	  first = false;
  }

  oseg = noseg;
	lbl[0] = 0;
	// Initialize constants into read-only data segment. Constants may be placed
	// in ROM along with code.
	if (sp->isConst) {
    oseg = rodataseg;
  }
	if (sp->storage_class == sc_thread) {
        if (sp->tp->type==bt_struct || sp->tp->type==bt_union)
           algn = imax(sp->tp->alignment,8);
        else if (sp->tp->type==bt_pointer)// && sp->tp->val_flag)
           algn = imax(sp->tp->GetBtp()->alignment,8);
        else
            algn = 2;
		seg(oseg==noseg ? tlsseg : oseg,algn);
		nl();
	}
	else if (sp->storage_class == sc_static || lastst==assign) {
        if (sp->tp->type==bt_struct || sp->tp->type==bt_union)
           algn = imax(sp->tp->alignment,8);
        else if (sp->tp->type==bt_pointer)// && sp->tp->val_flag)
           algn = imax(sp->tp->GetBtp()->alignment,8);
        else
            algn = 2;
		seg(oseg==noseg ? dataseg : oseg,algn);          /* initialize into data segment */
		nl();                   /* start a new line in object */
	}
	else {
        if (sp->tp->type==bt_struct || sp->tp->type==bt_union)
           algn = imax(sp->tp->alignment,8);
        else if (sp->tp->type==bt_pointer)// && sp->tp->val_flag)
           algn = imax(sp->tp->GetBtp()->alignment,8);
        else
            algn = 2;
		seg(oseg==noseg ? (lastst==assign ? dataseg : bssseg) : oseg,algn);            /* initialize into data segment */
		nl();                   /* start a new line in object */
	}
	
	if (sp->storage_class == sc_static || sp->storage_class == sc_thread) {
		//strcpy_s(glbl, sizeof(glbl), gen_label((int)sp->value.i, (char *)sp->name->c_str(), GetNamespace(), 'D'));
		if (sp->tp->IsSkippable()) {
			patchpoint = ofs.tellp();
			sprintf_s(buf, sizeof(buf), "\talign\t8\n\tdw\t$FFF0200000000001\n");
			ofs.printf(buf);
		}
		sp->realname = my_strdup(put_label((int)sp->value.i, (char *)sp->name->c_str(), GetNamespace(), 'D'));
		strcpy_s(glbl2, sizeof(glbl2), gen_label((int)sp->value.i, (char *)sp->name->c_str(), GetNamespace(), 'D'));
	}
	else {
		if (sp->storage_class == sc_global) {
			strcpy_s(lbl, sizeof(lbl), "public ");
			if (curseg==dataseg)
				strcat_s(lbl, sizeof(lbl), "data ");
			else if (curseg==bssseg)
				strcat_s(lbl, sizeof(lbl), "bss ");
			else if (curseg==tlsseg)
				strcat_s(lbl, sizeof(lbl), "tls ");
		}
		strcat_s(lbl, sizeof(lbl), sp->name->c_str());
		if (sp->tp->IsSkippable()) {
			patchpoint = ofs.tellp();
			sprintf_s(buf, sizeof(buf), "\talign\t8\n\tdw\t$FFF0200000000001\n");
			ofs.printf(buf);
		}
		strcpy_s(glbl2, sizeof(glbl2), sp->name->c_str());
		gen_strlab(lbl);
	}
	if (lastst == kw_firstcall) {
        GenerateByte(1);
        return;
    }
	else if( lastst != assign) {
		hasPointer = sp->tp->FindPointer();
		genstorage(sp->tp->size);
	}
	else {
		NextToken();
		hasPointer = sp->tp->FindPointer();
		typ_sp = 0;
		tp = sp->tp;
		push_typ(tp);
		while (tp = tp->GetBtp()) {
			push_typ(tp);
		}
		brace_level = 0;
		sp->tp->Initialize(nullptr);
		if (sp->tp->numele == 0) {
			if (sp->tp->GetBtp()) {
				if (sp->tp->GetBtp()->type == bt_char || sp->tp->GetBtp()->type == bt_uchar
					|| sp->tp->GetBtp()->type == bt_ichar || sp->tp->GetBtp()->type == bt_iuchar
					) {
					sp->tp->numele = laststrlen;
					sp->tp->size = laststrlen;
				}
			}
		}
	}
	if (!hasPointer && sp->tp->IsSkippable()) {
		endpoint = ofs.tellp();
		ofs.seekp(patchpoint);
		sprintf_s(buf, sizeof(buf), "\talign\t8\n\tdw\t$%I64X\n", ((genst_cumulative + 7LL) >> 3LL) | 0xFFF0200000000000LL);
		ofs.printf(buf);
		ofs.seekp(endpoint);
		genst_cumulative = 0;
	}