public ProcedureNode GetFirstMemberFunctionBy(string procName) { if (ProcTable == null) { return(null); } ProcedureNode procNode = ProcTable.GetFunctionsBy(procName).FirstOrDefault(); if (procNode != null) { return(procNode); } foreach (int baseClassIndex in Bases) { var baseClass = TypeSystem.classTable.ClassNodes[baseClassIndex]; procNode = baseClass.GetFirstMemberFunctionBy(procName); if (null != procNode) { break; } } return(procNode); }
public ProcedureNode GetFirstStaticFunctionBy(string procName, int argCount) { if (ProcTable == null) { return(null); } ProcedureNode procNode = ProcTable.GetFunctionsBy(procName, argCount) .Where(p => p.IsStatic) .FirstOrDefault(); if (procNode != null) { return(procNode); } foreach (int baseClassIndex in Bases) { var baseClass = TypeSystem.classTable.ClassNodes[baseClassIndex]; procNode = baseClass.GetFirstStaticFunctionBy(procName, argCount); if (null != procNode) { break; } } return(procNode); }
// 1. In some class's scope, classScope != kInvalidIndex; // 1.1 In the same class scope, return member function directly // 1.2 In the derive class scope, return member fucntion != kPrivate // 1.3 Return member function whose access == kPublic // // 2. In global scope, classScope == kInvalidIndex; public ProcedureNode GetMemberFunction(string procName, List <ProtoCore.Type> argTypeList, int classScope, out bool isAccessible, out int functionHostClassIndex, bool isStaticOrConstructor = false) { isAccessible = false; functionHostClassIndex = Constants.kInvalidIndex; if (ProcTable == null) { return(null); } ProcedureMatchOptions opts = new ProcedureMatchOptions() { FunctionName = procName, ParameterTypes = argTypeList, ExcludeAutoGeneratedThisProc = true, ExactMatchWithNumArgs = false, ExactMatchWithArgTypes = false, FilterCallback = x => (!isStaticOrConstructor) || (x.IsConstructor || x.IsStatic) }; int functionIndex = ProcTable.GetFunctionBySignature(opts, out ProcedureNode procNode); if (functionIndex != Constants.kInvalidIndex) { int myClassIndex = TypeSystem.classTable.IndexOf(Name); functionHostClassIndex = myClassIndex; procNode = ProcTable.Procedures[functionIndex]; if (classScope == Constants.kInvalidIndex) { isAccessible = (procNode.AccessModifier == CompilerDefinitions.AccessModifier.Public); } else if (classScope == myClassIndex) { isAccessible = true; } else if (TypeSystem.classTable.ClassNodes[classScope].IsMyBase(myClassIndex)) { isAccessible = (procNode.AccessModifier != CompilerDefinitions.AccessModifier.Private); } else { isAccessible = (procNode.AccessModifier == CompilerDefinitions.AccessModifier.Public); } return(procNode); } if (Base != Constants.kInvalidIndex) { procNode = TypeSystem.classTable.ClassNodes[Base].GetMemberFunction(procName, argTypeList, classScope, out isAccessible, out functionHostClassIndex, isStaticOrConstructor); } return(procNode); }
public ProcedureNode GetFirstConstructorBy(string procName, int argCount) { if (ProcTable == null) { return null; } return ProcTable.GetFunctionsByNameAndArgumentNumber(procName, argCount) .Where(p => p.IsConstructor) .FirstOrDefault(); }
public ProcedureNode GetFirstConstructorBy(string procName, int argCount) { if (ProcTable == null) { return(null); } return(ProcTable.GetFunctionsBy(procName, argCount) .Where(p => p.IsConstructor) .FirstOrDefault()); }
/// <summary> /// Returns all procedures which are called inside s1 /// </summary> /// <param name="s1"></param> /// <returns></returns> public List <string> CalledByProcedure(string s1) { var result = new List <string>(); var s1Ref = ProcTable.FirstOrDefault(p => p.ProcedureName == s1); if (s1Ref == null) { return(result); } return(s1Ref.CalledProcedures); }
public List <string> CalledByProcedure(string s1) { var result = new List <string>(); var s1Ref = ProcTable.FirstOrDefault(p => p.ProcedureName.Equals(s1, StringComparison.InvariantCultureIgnoreCase)); if (s1Ref == null) { return(result); } return(s1Ref.CalledProcedures); }
public ClassGenerator(DBConnectType ConnectType) { InitializeComponent(); da = new DataAccess(ConnectType); pt = new ProcTable(); g = new Generator(); pt.SetConnectionString(LoadServer.cn); if (TestAndLoad()) { btnGenerate.Enabled = true; } }
// 1. In some class's scope, classScope != kInvalidIndex; // 1.1 In the same class scope, return member function directly // 1.2 In the derive class scope, return member fucntion != kPrivate // 1.3 Return member function whose access == kPublic // // 2. In global scope, classScope == kInvalidIndex; public ProtoCore.DSASM.ProcedureNode GetMemberFunction(string procName, List <ProtoCore.Type> argTypeList, int classScope, out bool isAccessible, out int functionHostClassIndex, bool isStaticOrConstructor = false) { isAccessible = false; functionHostClassIndex = ProtoCore.DSASM.Constants.kInvalidIndex; if (ProcTable == null) { return(null); } ProtoCore.DSASM.ProcedureNode procNode = null; int functionIndex = ProcTable.IndexOf(procName, argTypeList, isStaticOrConstructor); if (functionIndex != ProtoCore.DSASM.Constants.kInvalidIndex) { int myClassIndex = TypeSystem.classTable.IndexOf(Name); functionHostClassIndex = myClassIndex; procNode = ProcTable.procList[functionIndex]; if (classScope == ProtoCore.DSASM.Constants.kInvalidIndex) { isAccessible = (procNode.AccessModifier == CompilerDefinitions.AccessModifier.kPublic); } else if (classScope == myClassIndex) { isAccessible = true; } else if (TypeSystem.classTable.ClassNodes[classScope].IsMyBase(myClassIndex)) { isAccessible = (procNode.AccessModifier != CompilerDefinitions.AccessModifier.kPrivate); } else { isAccessible = (procNode.AccessModifier == CompilerDefinitions.AccessModifier.kPublic); } return(procNode); } foreach (int baseClassIndex in Bases) { procNode = TypeSystem.classTable.ClassNodes[baseClassIndex].GetMemberFunction(procName, argTypeList, classScope, out isAccessible, out functionHostClassIndex, isStaticOrConstructor); if (procNode != null && isAccessible) { break; } } return(procNode); }
private ProcedureNode GetProcNode(string variableName) { if (ProcTable == null) { return(null); } Validity.Assert(null != variableName && variableName.Length > 0); string getterName = ProtoCore.DSASM.Constants.kGetterPrefix + variableName; var procNode = ProcTable.GetFunctionsByName(getterName).FirstOrDefault(); return(procNode); }
public ProcedureNode GetFirstMemberFunctionBy(string procName, int argCount) { if (ProcTable == null) { return null; } ProcedureNode procNode = ProcTable.GetFunctionsByNameAndArgumentNumber(procName, argCount).FirstOrDefault(); if (procNode != null) { return procNode; } if (Base != Constants.kInvalidIndex) { var baseClass = TypeSystem.classTable.ClassNodes[Base]; procNode = baseClass.GetFirstMemberFunctionBy(procName, argCount); } return procNode; }
private ProcedureNode GetProcNode(string variableName) { if (ProcTable == null) { return(null); } Validity.Assert(null != variableName && variableName.Length > 0); string getterName = ProtoCore.DSASM.Constants.kGetterPrefix + variableName; int index = ProcTable.IndexOfFirst(getterName); if (ProtoCore.DSASM.Constants.kInvalidIndex == index) { return(null); } return(ProcTable.procList[index]); }
//public bool Parent(int stmt1, int stmt2) //{ // //find statement by number in ast // AbstractSyntaxTree.PrintAst(); // return false; //} public bool Calls(string s1, string s2) { var s1Ref = ProcTable.FirstOrDefault(p => p.ProcedureName == s1); if (s1Ref == null) { return(false); } if (s1Ref.CalledProcedures.Contains(s2)) { return(true); } else { return(false); } }
public bool Calls(string s1, string s2) { var s1Ref = ProcTable.FirstOrDefault(p => p.ProcedureName.Equals(s1, StringComparison.InvariantCultureIgnoreCase)); if (s1Ref == null) { return(false); } if (s1Ref.CalledProcedures.Contains(s2, StringComparer.InvariantCultureIgnoreCase)) { return(true); } else { return(false); } }
public ProcedureNode GetFirstMemberFunctionBy(string procName) { if (ProcTable == null) { return(null); } ProcedureNode procNode = ProcTable.GetFunctionsByName(procName).FirstOrDefault(); if (procNode != null) { return(procNode); } if (Base != Constants.kInvalidIndex) { var baseClass = TypeSystem.classTable.ClassNodes[Base]; procNode = baseClass.GetFirstMemberFunctionBy(procName); } return(procNode); }