public virtual ktValue GetMember(ktString Name) { ktValue Value = ktValue.Null; try { Value = GetProperty(Name); //ktDebug.Log( "GM::P V:" + Value.ToString() + ";" ); if (!Value.IsNull()) { return Value; } } catch (Exception) { //ktDebug.Log( "Err:" + E.ToString() + ";" ); } try { ktFunction Func = GetMethod(Name); Value = new ktValue(Name, "ktFunction", Func, true, true); if (!Value.IsNull()) { return Value; } } catch (Exception) { if (Name == "Export") { ktDelegateFunction Func = new ktDelegateFunction("Export", ExportValue); Value = new ktValue(Name, "ktFunction", Func, true, true); if (!Value.IsNull()) { return Value; } } else if (Name.AsLower() == "tostring") { ktDelegateFunction Func = new ktDelegateFunction("ToString", ToStringValue); Value = new ktValue(Name, "ktFunction", Func, true, true); if (!Value.IsNull()) { return Value; } } } throw new ktError("Can't find the member '" + Name + "' in class '" + m_Name + "'!", ktERR._404); }
protected ktValue HandleCompAssignment(ktList Target, ktValue Value) { bool Constant = false, Hard = false; ktString Name = new ktString(), ClassName = null; ktToken Token = null; ktClass Class = null; #if Debug ktDebug.Log( "HCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCAHCA" ); #endif ktDebug.Log("HCA: V:" + Value.Export() + "\n" + Target.Get_R()); Target.Reset(); foreach (ktList L in Target) { if ((L.Node == null) || (L.Node.Value == null)) { continue; } Token = (ktToken)L.Node.Value; #if Debug ktDebug.Log( "HCA:" + Token.ToString() ); #endif switch (Token.Type) { case ktTokenType.Const: { if (Constant) { throw new ktError("Unexpected " + Token.ToString() + " on line " + Token.LineNo.ToString() + " by character " + Token.CharPos.ToString() + "!", ktERR.UNEXP); } Constant = true; break; } case ktTokenType.Hard: { if (Hard) { throw new ktError("Unexpected " + Token.ToString() + " on line " + Token.LineNo.ToString() + " by character " + Token.CharPos.ToString() + "!", ktERR.UNEXP); } Hard = true; break; } case ktTokenType.Id: { if (!Name.IsEmpty()) { try { Class = GetClass(Name); ClassName = Name; Hard = true; } catch (Exception) { throw new ktError("Unexpected " + Token.ToString() + " (" + Token.Value + ") on line " + Token.LineNo.ToString() + " by character " + Token.CharPos.ToString() + "!", ktERR.UNEXP); } } Name = Token.Value; break; } } } Value.Constant = Constant; Value.HardType = Hard; if (!Value.IsNull()) { ((ktClass)Value.Value).HardType = Hard; ((ktClass)Value.Value).IsConstant = Constant; } if (Class != null) { ktList Arg = new ktList(); ktClass Obj = Class.CreateObject(); Obj.HardType = Hard; Obj.IsConstant = Constant; if (!Value.IsNull()) { Arg.Add(Value); Obj.RunMethod("Assign", Arg); } Value = new ktValue(Name, ClassName, Obj, Hard, Constant); } SetVariable(Name, true, Value, true, true); return Value; }