All pastes #749745 Raw Edit

Someone

public text v1 · immutable
#749745 ·published 2007-10-25 21:57 UTC
rendered paste body
alias void* delegate(void* delegate()[]) precedure;
alias void* function(void* delegate()[]) precedureFunction;

struct _scope{
	precedure[char[]] descriptions;
	_scope* parent;
	
	precedure getFunc(char[] operator){
		if(precedure* func = operator.isIn())
			return *func;
		else if(operator.isNumeric()){
			writefln(operator.toInt());
			return cast(precedure){return cast(void*)operator.toInt();};
		}
		else
			return cast(precedure){return cast(void*)operator;};
	}

	precedure* isIn(char[] operator){
		if(precedure* func = operator in descriptions)
			return func;
		else{
			if(parent)
				return parent.isIn(operator);
			else
				return null;
		}
	}
	
	void add(char[] operator, precedure lamda){
		descriptions[operator] = lamda;
	}
	
	void add(char[] operator, precedureFunction lamda){
		void* execute(void* delegate()[] args){
			return lamda(args);
		}
		add(operator, &execute);
	}
}