bool ASTPrinter::visit(Identifier const& _node) { writeLine(string("Identifier ") + _node.getName()); printType(_node); printSourcePart(_node); return goDeeper(); }
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; } } } } }
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; }
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"); } }
virtual std::string getName() { if(identifier) return identifier->getName(); return ""; }
virtual std::string asString() { return id->getName(); }
std::string getName() { return id->getName(); }