public static bool InvokeFunc(ELEMENT ie, object[] args, xmlScriptObj baseObj, STACKVAL stack, out object o) { // ref : http://dobon.net/vb/dotnet/programing/typegetmember.html o = null; ELEMENT e = ie; ELEMENT last = e.GetPointerLast(); string func = last.raw; object p = null; Type t = null; p = GetPropaty(e, baseObj, stack); if (p != null) { t = xmlScriptGetMethod.ObjectGetType(p); } else //if (xmlEtc.CountCharInString(pointerstr,'.') == 1) // **.**. { string pointerstr = e.GetPointerString(); t = GetTypeOf(pointerstr); } if (t == null) { throw new SystemException("ERROR CAN'T SOLVE TYPE :" + e.GetPointerString()); } if (string.IsNullOrEmpty(func) || t == null) { throw new SystemException("ERROR NOT DEFINED FUNC NAME"); } return(__InvokeFunc(last, args, ref o, func, p, t)); }
public static object CreateNewObject(ELEMENT e, object[] args, xmlScriptObj scrObj, STACKVAL stack) { ELEMENT last = e.GetPointerLast(); string pointerstr = e.GetPointerString(); string name = string.IsNullOrEmpty(pointerstr) ? last.raw : pointerstr + "." + last.raw; object o = null; var t = GetTypeOf(name); if (hglEtc.check_head(t.ToString(), "xmlScriptJS.")) { if (args != null) { var jsargs = new xmlScriptJS.ARGS(); jsargs.m_args = args; o = System.Activator.CreateInstance(t, jsargs); } else { o = System.Activator.CreateInstance(t); } return(o); } var nargs = xmlScriptGetMethod.CreateArgsForCreateInstance(t, args); o = System.Activator.CreateInstance(t, nargs); return(o); }
public static bool ExecutePointer(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack, out object o) { ELEMENT last = e.GetPointerLast(); var pointerstr = e.GetPointerString(); if (xmlScriptExecFunc.ExecuteFunction(e, scrObj, stack, out o)) { return(true); } if (xmlScriptExecVar.ExecuteVariable(e, scrObj, stack, out o)) { return(true); } throw new SystemException("ERROR EXECUTE POINTER" + e.raw); }
public static bool ExecuteSetPointer(ELEMENT e, object val, xmlScriptObj scrObj, STACKVAL stack) { if (!e.isPOINTER()) { return(false); } ELEMENT last = e.GetPointerLast(); var pointerstr = e.GetPointerString(); // GetPointerToString(e,out last ); var o = xmlScriptReflection.SetPropaty(e, new object[] { val }, scrObj, stack); if (o != null) { return(true); } return(false); }
public static bool ExecuteVariable(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack, out object o) { string pointerstr = e.GetPointerString(); ELEMENT last = e.GetPointerLast(); if (e.isVARIABLE()) { if (ExecuteValiable_GetFromStack(e, scrObj, stack, out o)) { return(true); } } o = xmlScriptReflection.GetPropaty(e, scrObj, stack); if (o != null) { return(true); } return(false); }
public static bool ExecuteFunction(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack, out object o) { o = null; object[] arglist = null; ELEMENT func = e.GetPointerLast(); if (!func.isFUNCTION()) { return(false); } if (func.raw == "typeof") { if (func.GetListElement(0).isBLOCK_C()) { var p0e = func.GetListElement(0).GetListElement(0); ELEMENT last = p0e.GetPointerLast(); var pstr = p0e.GetPointerString(); pstr = string.IsNullOrEmpty(pstr) ? last.raw : pstr + "." + last.raw; Type t = xmlScriptReflection.GetTypeOf(pstr); if (t == null) { var o_1 = xmlScriptFunc.Execute(p0e, scrObj, stack); if (o_1 != null) { t = xmlScriptGetMethod.ObjectGetType(o_1); } } o = t; return(true); } return(false); } if (func.raw == "SETUPDATEFUNC" /*"S_SetUpdateFunc"*/) { if (func.GetListElement(0).isBLOCK_C()) { var p0 = func.GetListElement(0).GetListElement(0); var p1 = func.GetListElement(0).GetListElement(1); var p0_o = xmlScriptFunc.Execute(p0, scrObj, stack); var funcname = (p1.isQUOTE() ? p1.raw : null); if (!string.IsNullOrEmpty(funcname) && xmlScriptGetMethod.ObjectGetType(p0_o) == typeof(GameObject)) { var scriptMan = scrObj.GetComponent <xmlScriptMan>(); if (scriptMan != null) { scriptMan.SetUpdate(funcname, (GameObject)p0_o); return(true); } } } return(false); } else if (func.raw == "SETSTARTFUNC") { if (func.GetListElement(0).isBLOCK_C()) { var p0 = func.GetListElement(0).GetListElement(0); var p1 = func.GetListElement(0).GetListElement(1); var p0_o = xmlScriptFunc.Execute(p0, scrObj, stack); var p1_o = xmlScriptFunc.Execute(p1, scrObj, stack); //var funcname = p1_o.ToString(); if (p1_o != null && !string.IsNullOrEmpty(p1_o.ToString()) && (p0_o == null || xmlScriptGetMethod.ObjectGetType(p0_o) == typeof(GameObject))) { var scriptMan = scrObj.GetComponent <xmlScriptMan>(); if (scriptMan != null) { scriptMan.SetStart(p1_o.ToString(), (GameObject)p0_o); return(true); } } } return(false); } else if (func.raw == "CALL") { if (func.GetListElement(0).isBLOCK_C()) { var p0 = func.GetListElement(0).GetListElement(0); var p0_o = xmlScriptFunc.Execute(p0, scrObj, stack); //var funcname = p1_o.ToString(); if (p0_o != null && !string.IsNullOrEmpty(p0_o.ToString())) { var scriptMan = scrObj.GetComponent <xmlScriptMan>(); if (scriptMan != null) { scrObj.m_scriptMan.RunFunction(p0_o.ToString(), null, scrObj); return(true); } } } return(false); } arglist = GetArgs(func.GetListElement(0), scrObj, stack); if (e == func) { if (xmlScriptFunc.CallScriptFunction(func.raw, scrObj, stack, arglist, out o)) { if (o != null && xmlScriptGetMethod.ObjectGetType(o) == typeof(SENTENCE_STATE)) { var ss = (SENTENCE_STATE)o; if (ss.state == SENTENCE_STATE.STATE.RETURN) { o = ss.ret; } } return(true); } } else { var pointerstr = e.GetPointerString(); if (xmlScriptReflection.InvokeFunc(e, arglist, scrObj, stack, out o)) { return(true); } } return(false); }