Exemplo n.º 1
0
	internal static DynamicEnv find(Symbol s)
		{
		for(DynamicEnv d = denv;d != null;d = d.next)
			{
			if(d.sym == s)
				return d;
			}
		return null;
		}
Exemplo n.º 2
0
 internal Parameter(Symbol symbol, Spec spec, IExpression initCode)
 {
     if(symbol.isDynamic)
     throw new Exception("Dynamic variables cannot be parameters to functions or let");
     if(symbol is Keyword)
     throw new Exception("Keywords cannot be parameters to functions or let");
     this.symbol = symbol;
     this.spec = spec;
     this.initCode = initCode;
 }
Exemplo n.º 3
0
	internal Object lookup(Symbol var) 
		{
		Int32 level = 0;
		for(Env e = this;e.parent != null;e = e.parent,++level)
			{
			for(Int32 i = 0;i<e.vars.Length;i++)
				{
				if(e.vars[i].symbol == var)
					return new LocalVariable(level, i, var);
				}
			}
		return var;
		}
Exemplo n.º 4
0
 public override bool IsSubscriberOf(string eventName)
 {
     if (!eventName.Contains("."))
     {
         eventName = eventName.ToLower();
     }
     DotLisp.Symbol o = dotLispInterpreter.intern(eventName);//.Read("DefinedFunction", new System.IO.StringReader(eventName));
     if (o != null && o.isDefined())
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
 internal ApplyExpression(Cons args,Env env,Interpreter interpreter,Loc loc)
 {
     this.loc = loc;
     this.interpreter = interpreter;
     fexpr = interpreter.analyze(args.first,env,loc);
     if(fexpr is IVar)
     {
     fsym = ((IVar)fexpr).getSymbol();
     }
     Int32 len = Cons.Length(args.rest);
     argexprs = new IExpression[len];
     args = args.rest;
     for(Int32 i=0;i<argexprs.Length;i++,args = args.rest)
     {
     argexprs[i] = interpreter.analyze(args.first,env,loc);
     }
 }
Exemplo n.º 6
0
	internal Symbol intern(String name)
		{
		Symbol result = (Symbol)table[name];
		if(result == null)
			{
			if(name.StartsWith(":"))
				{
				table[name] = result = new Keyword(name);
				}
			else
				{
				int firstdot = name.IndexOf('.');
				int lastdot = name.LastIndexOf('.'); 
				int lastcolon = name.LastIndexOf(':'); 
				int nameLength=name.Length;

				// .instance
				// .[namespace.]type:explicitinstance
				// [namespace.]type.
				// [namespace.]type:static
				// obj.member - transformed by reader
				if((firstdot != -1 || lastcolon != -1) && nameLength > 1)
					{
					if(firstdot == 0)	//instance
						{
						if(lastcolon > 0)	  //explicitly qualified
							{
							String memberName = name.Substring(lastcolon+1,nameLength-(lastcolon+1));
							Type type = findType(name.Substring(1,lastcolon-1));
							table[name] = result = new CLSInstanceSymbol(name,memberName,type);
							}
						else
							{
							String memberName = name.Substring(1,nameLength-1);
							table[name] = result = new CLSInstanceSymbol(name,memberName,null);
							}
						}
					else if(lastcolon > 0)	//static
						{
						String memberName = name.Substring(lastcolon+1,nameLength-(lastcolon+1));
						Type type = findType(name.Substring(0,lastcolon));
						table[name] = result = new CLSStaticSymbol(name,memberName,type);
						}
					else if(lastdot==nameLength-1) //type
						{
						Type type = findType(name.Substring(0,lastdot));
						table[name] = result = new CLSTypeSymbol(name,type);
						}
					}
				else
					{
					table[name] = result = new Symbol(name);
					result.isDynamic = (name[0] == '*');
					}
				}
			}
		return result;
		}
 public override object GetSymbol(string eventName)
 {
     eventName = eventName.ToLower();
     DotLisp.Symbol o = dotLispInterpreter.intern(eventName);//.Read("DefinedFunction", new System.IO.StringReader(eventName));
     return(o);
 }
Exemplo n.º 8
0
 void internBuiltins()
 {
     BLOCK = intern("block");
     SET              = intern("__set");
     FIRST           = intern("first");
     REST            = intern("rest");
     DEF            = intern("def");
     IF              = intern("if");
     FN          = intern("fn");
     MACRO            = intern("macro");
     OR               = intern("or");
     WHILE           = intern("while");
     BREAK       = intern(":break");
     AMPOPT         = intern("&opt");
     AMPKEY          = intern("&key");
     AMPREST         = intern("&rest");
     QUOTE            = intern("quote");
     DLET            = intern("dynamic-let");
     STR            = intern("str");
     VECTOR         = intern("vector");
     COMPARE        = intern("compare");
     BACKQUOTE      = intern("backquote");
     UNQUOTE          = intern("unquote");
     UNQUOTE_SPLICING = intern("unquote-splicing");
     NIL            = internConstant("nil",null);
     TRUE        = internConstant("true",true);
     FALSE       = internConstant("false",false);
     EX          = intern("!");
     LASTVAL        = intern("$");
     NEXTLASTVAL    = intern("$$");
     THIRDLASTVAL   = intern("$$$");
     EOF            = intern(":eof");
 }
Exemplo n.º 9
0
 public void UnTrace(Symbol s)
 {
     traceList.Remove(s);
 }
Exemplo n.º 10
0
 public void Trace(Symbol s)
 {
     traceList[s] = null;
 }
Exemplo n.º 11
0
	internal DynamicVar(Symbol s)
		{
		this.sym = s;
		}
Exemplo n.º 12
0
	internal GlobalVar(Symbol s)
		{
		this.sym = s;
		}
Exemplo n.º 13
0
	internal LocalVariable(Int32 level, Int32 index, Symbol name) 
		{
		this.level = level; 
		this.index = index; 
		this.sym = name;
		}
Exemplo n.º 14
0
	private DynamicEnv(Symbol sym,Object val, DynamicEnv next)
		{
		this.sym = sym;
		this.val = val;
		this.next = next;
		}
Exemplo n.º 15
0
	internal static void extend(Symbol sym, Object val)
		{
		if(!sym.isDynamic)
			throw new Exception("Dynamic vars must have prefix *");
		denv = new DynamicEnv(sym,val,denv);
		}