public List <MethodMirror> GetOverloads(string methodName) { List <MethodMirror> methods = new List <MethodMirror>(); string name = string.Empty; if (classNode == null) { Validity.Assert(staticCore != null); ProtoCore.DSASM.ClassTable classTable = staticCore.ClassTable; int ci = classTable.IndexOf(ClassName); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } } ProcedureTable procedureTable = classNode.vtable; List <ProcedureNode> procList = procedureTable.procList; foreach (ProcedureNode pNode in procList) { name = pNode.name; if (name == methodName) { methods.Add(new MethodMirror(pNode)); } } return(methods); }
/// <summary> /// Returns the list of constructors defined for the given class /// </summary> /// <returns></returns> public List <MethodMirror> GetConstructors() { List <MethodMirror> constructors = new List <MethodMirror>(); if (classNode == null) { Validity.Assert(staticCore != null); ProtoCore.DSASM.ClassTable classTable = staticCore.ClassTable; int ci = classTable.IndexOf(ClassName); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } } ProcedureTable procedureTable = classNode.vtable; List <ProcedureNode> procList = procedureTable.procList; foreach (ProcedureNode pNode in procList) { if (pNode.isConstructor == true) { constructors.Add(new MethodMirror(pNode)); } } return(constructors); }
/// <summary> /// Returns the list of function properties of the class only /// </summary> /// <returns> function nodes </returns> public List <MethodMirror> GetFunctions() { List <MethodMirror> methods = new List <MethodMirror>(); string name = string.Empty; if (classNode == null) { Validity.Assert(staticCore != null); ProtoCore.DSASM.ClassTable classTable = staticCore.ClassTable; int ci = classTable.IndexOf(ClassName); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } } ProcedureTable procedureTable = classNode.vtable; List <ProcedureNode> procList = procedureTable.procList; foreach (ProcedureNode pNode in procList) { name = pNode.name; if (!pNode.isAssocOperator && !pNode.isAutoGenerated && !pNode.isAutoGeneratedThisProc && !pNode.isConstructor) { methods.Add(new MethodMirror(pNode)); } } return(methods); }
/// <summary> /// Returns the base class hierarchy for the given class /// </summary> /// <returns></returns> public List <ClassMirror> GetClassHierarchy() { List <ClassMirror> baseClasses = new List <ClassMirror>(); Validity.Assert(!string.IsNullOrEmpty(ClassName)); Validity.Assert(staticCore != null); int ci; if (classNode == null) { ProtoCore.DSASM.ClassTable classTable = staticCore.ClassTable; ci = classTable.IndexOf(ClassName); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } } ClassNode cNode = classNode; while (cNode.baseList.Count > 0) { ci = cNode.baseList[0]; Validity.Assert(ci != ProtoCore.DSASM.Constants.kInvalidIndex); baseClasses.Add(new ClassMirror(staticCore, staticCore.ClassTable.ClassNodes[ci], this.libraryMirror)); cNode = staticCore.ClassTable.ClassNodes[ci]; } return(baseClasses); }
public ClassMirror(string className, ProtoCore.Core core) : base(core, className) { if (core == null) { return; } ClassName = className; if (classNode == null) { ProtoCore.DSASM.ClassTable classTable = core.ClassTable; int ci = classTable.IndexOf(ClassName); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } else { throw new Exception(String.Format("Class {0} not defined", className)); } } libraryMirror = new LibraryMirror(classNode.ExternLib, core); }
/// <summary> /// Returns the list of class properties of this class /// </summary> /// <returns> symbol nodes</returns> public List <PropertyMirror> GetProperties() { List <PropertyMirror> properties = new List <PropertyMirror>(); Dictionary <string, ProcedureNode> setterMap = new Dictionary <string, ProcedureNode>(); string name = string.Empty; if (classNode == null) { Validity.Assert(staticCore != null); ProtoCore.DSASM.ClassTable classTable = staticCore.ClassTable; int ci = classTable.IndexOf(ClassName); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } } ProcedureTable procedureTable = classNode.vtable; List <ProcedureNode> procList = procedureTable.procList; string getterPrefix = ProtoCore.DSASM.Constants.kGetterPrefix; string setterPrefix = ProtoCore.DSASM.Constants.kSetterPrefix; foreach (ProcedureNode pNode in procList) { name = pNode.name; if (name.Contains(getterPrefix) && pNode.argInfoList.Count == 0) { properties.Add(new PropertyMirror(pNode)); } else if (name.Contains(setterPrefix) && pNode.argInfoList.Count == 1 && !pNode.isAutoGeneratedThisProc) { if (setterMap.ContainsKey(name)) { ProcedureNode proc = setterMap[name]; if (proc.argTypeList[0].UID == (int)ProtoCore.PrimitiveType.kTypeVar && pNode.argTypeList[0].UID != (int)ProtoCore.PrimitiveType.kTypeVar) { setterMap.Remove(name); setterMap.Add(name, pNode); } } else { setterMap.Add(name, pNode); } } } foreach (var kvp in setterMap) { properties.Add(new PropertyMirror(kvp.Value, true)); } return(properties); }
public MethodMirror GetDeclaredMethod(string className, string methodName, List <ProtoCore.Type> argumentTypes) { // Check global methods if classname is empty or null if (string.IsNullOrEmpty(className)) { List <MethodMirror> methods = null; methods = GetGlobalMethods(); foreach (var method in methods) { if (method.MethodName == methodName) { List <ProtoCore.Type> argTypes = method.GetArgumentTypes(); if (argTypes.Count == argumentTypes.Count) { bool isEqual = true; for (int i = 0; i < argumentTypes.Count; ++i) { if (!argumentTypes[i].Equals(argTypes[i])) { isEqual = false; break; } } if (isEqual) { return(method); } } } } } else // find method in Class { Validity.Assert(staticCore != null); ClassNode classNode = null; ProtoCore.DSASM.ClassTable classTable = staticCore.ClassTable; int ci = classTable.IndexOf(className); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } ProcedureTable procedureTable = classNode.vtable; List <ProcedureNode> procList = procedureTable.procList; return(StaticMirror.FindMethod(methodName, argumentTypes, procList)); } return(null); }
public MethodMirror GetDeclaredMethod(string methodName, List <ProtoCore.Type> argumentTypes) { if (classNode == null) { Validity.Assert(staticCore != null); ProtoCore.DSASM.ClassTable classTable = staticCore.ClassTable; int ci = classTable.IndexOf(ClassName); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } } ProcedureTable procedureTable = classNode.vtable; List <ProcedureNode> procList = procedureTable.procList; return(StaticMirror.FindMethod(methodName, argumentTypes, procList)); }
public ClassMirror(string className, ProtoCore.Core core) : base(core) { if (core == null) { return; } ClassName = className; if (classNode == null) { ProtoCore.DSASM.ClassTable classTable = core.ClassTable; int ci = classTable.IndexOf(ClassName); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } } libraryMirror = new LibraryMirror(classNode.ExternLib, core); }
/// <summary> /// Get the super class of this class /// </summary> /// <returns></returns> public ClassMirror GetSuperClass() { Validity.Assert(!string.IsNullOrEmpty(ClassName)); Validity.Assert(staticCore != null); int ci; if (classNode == null) { ProtoCore.DSASM.ClassTable classTable = staticCore.ClassTable; ci = classTable.IndexOf(ClassName); if (ci != ProtoCore.DSASM.Constants.kInvalidIndex) { classNode = classTable.ClassNodes[ci]; } } ci = classNode.baseList[0]; Validity.Assert(ci != ProtoCore.DSASM.Constants.kInvalidIndex); return(new ClassMirror(staticCore, staticCore.ClassTable.ClassNodes[ci], this.libraryMirror)); }
/// <summary> /// Given a partial class name, get assembly to which the class belongs /// </summary> /// <param name="classTable"> class table in Core </param> /// <param name="className"> class name </param> /// <returns> assembly to which the class belongs </returns> public static string GetAssemblyFromClassName(ClassTable classTable, string className) { //throw new NotImplementedException(); var ci = classTable.IndexOf(className); if (ci == ProtoCore.DSASM.Constants.kInvalidIndex) return string.Empty; var classNode = classTable.ClassNodes[ci]; return classNode.ExternLib; }