Ejemplo n.º 1
0
bool ASTPrinter::visit(Identifier const& _node)
{
	writeLine(string("Identifier ") + _node.getName());
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Ejemplo n.º 2
0
    UserDefinedFunction::UserDefinedFunction( Operands *operands ) : Object( __function_t ){
        closureLink = NULL;
        // get the function name.
        Identifier *name = CAST_TO( Identifier, operands->get(0) );
		if( name != NULL ){
		    char *tmpName = name->getName();		    
            functName = new char[ strlen(tmpName) + 1 ];
            strcpy( functName, tmpName );
			//operands->pop_front();
			// get the formalParameter list.
			fpList = CAST_TO( FormalParameterList, operands->get(1) );
			if( fpList != NULL ){
			    //operands->pop_front();
				// get the returnType.
				Type *dataType = CAST_TO( Type, operands->get(2) );
				if( dataType != NULL ){
                    returnType = dataType->getDataType();
                    //operands->pop_front();
                    // get the statementList of the function.
                    functBody = CAST_TO( StatementList, operands->get(3) );
                    if( functBody == NULL ){
                        cout<<"Error in udf.."<<endl;
                    }
                }
            }
        }
    }
Ejemplo n.º 3
0
const SharedString& Declaration::mangledName() const
{
	if (_mangledName.empty())
	{
		for (auto a : _attributes)
		{
			Identifier *i = dynamic_cast<Identifier*>(a);
			if (i && i->getName().eq("extern_c"))
			{
				_mangledName = name();
				return _mangledName;
			}
		}
		_mangledName = SharedString(Concat, "_M", mangleof()); // TODO: include scope...
	}
	return _mangledName;
}
Ejemplo n.º 4
0
void Arg::setup() {
  // If two children, the first is the name.  Otherwise, name is "".
  if (1 == children.size()) {
    m_typeSpec = dynamic_cast<TypeSpec*>(children.at(0));
  } else if (2 == children.size()) {
    m_typeSpec = dynamic_cast<TypeSpec*>(children.at(1));
    Identifier* ident = dynamic_cast<Identifier*>(children.at(0));
    if (!ident) {
      throw CompileError("First child of 2-child Arg " + print() + " must be an Identifier");
    }
    m_argname = ident->getName();
  } else {
    throw CompileError("Arg node must have 1 or 2 children");
  }
  if (!m_typeSpec) {
    throw CompileError("Arg " + print() + " must have a TypeSpec child");
  }
}
Ejemplo n.º 5
0
 virtual std::string getName() {
     if(identifier) return identifier->getName();
     return "";
 }
Ejemplo n.º 6
0
 virtual std::string asString() { return id->getName(); }
Ejemplo n.º 7
0
 std::string getName() { return id->getName(); }