Exemple #1
0
/**
 * Define a symbol with a particular Signature in the current scope. If
 * redefinition is explicitly allowed (as it might have to be for internals),
 * shut up about redefined symbols.
 */
void Context::define(const Signature& signature,
	std::shared_ptr<const Expression> body, bool allow_redefinition) {

	if (!allow_redefinition) {
		auto position = stack.front().symbols.find(signature);
		if (position != stack.front().symbols.end()) {
			std::ostringstream message;
			message << "Redefinition of \"" << signature.name
				<< "\"";
			if (!stack.front().name.empty())
				message << " in namespace \"" << stack.front().name << "\"";
			message << " already defined as \"" << position->first.canonical
				<< "\".";
			throw std::runtime_error(message.str());
		}
	}

	stack.front().symbols[signature] = body;

	std::string qualified = signature.name;

	auto frame = stack.begin();
	auto previous = frame++;
	while (frame != stack.end() && !previous->name.empty()) {
		qualified = previous->name + "::" + qualified;
		Signature prefixed(qualified, signature);
		frame->symbols[prefixed] = body;
		previous = frame++;
	}

}
Exemple #2
0
/*
**	Add the directory icon.
*/
PUBLIC BOOL HTIcon_addDir (const char * url, const char * prefix, char * alt)
{
    if ((icon_dir = (HTIconNode *) HT_CALLOC(1,sizeof(HTIconNode))) == NULL)
        HT_OUTOFMEM("HTAddBlankIcon");
    if (url) icon_dir->icon_url = prefixed(url, prefix);
    if (alt) StrAllocCopy(icon_dir->icon_alt, alt);
    alt_resize(alt);
    HTTRACE(PROT_TRACE, "Icon add.... DIRECTORY => SRC=\"%s\" ALT=\"%s\"\n" _ url _ 
		alt ? alt : "");
    return YES;
}
Exemple #3
0
/*
**	HTAddIcon(url, alt, type_templ) adds icon:
**
**		<IMG SRC="url" ALT="[alt]">
**
**	for files for which content-type or content-encoding matches
**	type_templ.  If type_templ contains a slash, it is taken to be
**	a content-type template.  Otherwise, it is a content-encoding
**	template.
*/
PUBLIC BOOL HTIcon_add (const char * url, const char * prefix,
			char * alt, char * type_templ)
{
    if (url && type_templ) {
	HTIconNode * node;
	if ((node = (HTIconNode *) HT_CALLOC(1,sizeof(HTIconNode))) == NULL)
	    HT_OUTOFMEM("HTAddIcon");
	if (url) node->icon_url = prefixed(url, prefix);
	if (alt) StrAllocCopy(node->icon_alt, alt);
	if (type_templ) StrAllocCopy(node->type_templ, type_templ);
	if (!icons) icons = HTList_new();
	HTList_addObject(icons, (void *) node);
	alt_resize(alt);
	HTTRACE(PROT_TRACE, "AddIcon..... %s => SRC=\"%s\" ALT=\"%s\"\n" _ 
		    type_templ _ url _ alt ? alt : "");
	return YES;
    }
    return NO;
}
Exemple #4
0
PUBLIC void HTStdIconInit ARGS1(CONST char *, url_prefix)
{
    CONST char * p = url_prefix ? url_prefix : "/internal-icon/";

    HTAddBlankIcon  (prefixed(p,"blank.xbm"),	NULL	);
    HTAddDirIcon    (prefixed(p,"directory.xbm"),"DIR"	);
    HTAddParentIcon (prefixed(p,"back.xbm"),	"UP"	);
    HTAddUnknownIcon(prefixed(p,"unknown.xbm"),	NULL	);
    HTAddIcon(prefixed(p,"unknown.xbm"),	NULL,	"*/*");
    HTAddIcon(prefixed(p,"binary.xbm"),		"BIN",	"binary");
    HTAddIcon(prefixed(p,"unknown.xbm"),	NULL,	"www/unknown");
    HTAddIcon(prefixed(p,"text.xbm"),		"TXT",	"text/*");
    HTAddIcon(prefixed(p,"image.xbm"),		"IMG",	"image/*");
    HTAddIcon(prefixed(p,"movie.xbm"),		"MOV",	"video/*");
    HTAddIcon(prefixed(p,"sound.xbm"),		"AU",	"audio/*");
    HTAddIcon(prefixed(p,"compressed.xbm"),	"CMP",	"compress");
    HTAddIcon(prefixed(p,"compressed.xbm"),	"GZP",	"gzip");
    HTAddIcon(prefixed(p,"index.xbm"),		"IDX",	"application/x-gopher-index");
    HTAddIcon(prefixed(p,"index2.xbm"),		"CSO",	"application/x-gopher-cso");
    HTAddIcon(prefixed(p,"telnet.xbm"),		"TEL",	"application/x-gopher-telnet");
    HTAddIcon(prefixed(p,"unknown.xbm"),       	"DUP",	"application/x-gopher-duplicate");
    HTAddIcon(prefixed(p,"unknown.xbm"),	"TN",	"application/x-gopher-tn3270");
}