diff --git a/Core/GraphToDSCompiler/AstCodeBlockTraverse.cs b/Core/GraphToDSCompiler/AstCodeBlockTraverse.cs index 51122a0..668784d 100644 --- a/Core/GraphToDSCompiler/AstCodeBlockTraverse.cs +++ b/Core/GraphToDSCompiler/AstCodeBlockTraverse.cs @@ -17,16 +17,14 @@ public class AstCodeBlockTraverse /// protected ProtoCore.AST.AssociativeAST.BinaryExpressionNode ChildTree { get; set; } - public AstCodeBlockTraverse(List astList) - //: base(astList) - { } + public AstCodeBlockTraverse() { } public AstCodeBlockTraverse(ProtoCore.AST.AssociativeAST.BinaryExpressionNode bNode) { ChildTree = bNode; } - protected void EmitIdentifierNode(ref ProtoCore.AST.AssociativeAST.AssociativeNode identNode) + protected virtual void EmitIdentifierNode(ref ProtoCore.AST.AssociativeAST.AssociativeNode identNode) { ProtoCore.AST.AssociativeAST.IdentifierNode iNode = ChildTree.LeftNode as ProtoCore.AST.AssociativeAST.IdentifierNode; @@ -42,6 +40,12 @@ protected void EmitIdentifierNode(ref ProtoCore.AST.AssociativeAST.AssociativeNo } } + //======================= + + /// + /// Depth first traversal of an AST node + /// + /// public void DFSTraverse(ref ProtoCore.AST.AssociativeAST.AssociativeNode node) { if (node is ProtoCore.AST.AssociativeAST.IdentifierNode) @@ -110,13 +114,6 @@ public void DFSTraverse(ref ProtoCore.AST.AssociativeAST.AssociativeNode node) } - //======================= - - /// - /// Depth first traversal of an AST node - /// - /// - /// /// These functions emit the DesignScript code on the destination stream /// @@ -136,7 +133,7 @@ private void EmitArrayIndexerNode(ref ProtoCore.AST.AssociativeAST.ArrayIndexerN } } - private void EmitExprListNode(ref ProtoCore.AST.AssociativeAST.ExprListNode exprListNode) + protected virtual void EmitExprListNode(ref ProtoCore.AST.AssociativeAST.ExprListNode exprListNode) { for (int i = 0; i < exprListNode.list.Count; i++) { @@ -184,6 +181,7 @@ protected virtual void EmitFunctionCallNode(ref ProtoCore.AST.AssociativeAST.Fun funcCallNode.FormalArguments[n] = argNode; if (n + 1 < funcCallNode.FormalArguments.Count) { + } } } diff --git a/Core/ProtoCore/Reflection/Mirror.cs b/Core/ProtoCore/Reflection/Mirror.cs index 15f921b..b8742f1 100644 --- a/Core/ProtoCore/Reflection/Mirror.cs +++ b/Core/ProtoCore/Reflection/Mirror.cs @@ -365,7 +365,7 @@ protected static MethodMirror FindMethod(string methodName, List } } if (isEqual) - return new MethodMirror(procNode); + return new MethodMirror(procNode, staticCore); } } } @@ -389,7 +389,7 @@ private static List GetBuiltInMethods() { if (!procNode.name.StartsWith(ProtoCore.DSASM.Constants.kInternalNamePrefix) && !procNode.name.Equals("Break")) { - MethodMirror builtIn = new MethodMirror(procNode); + MethodMirror builtIn = new MethodMirror(procNode, staticCore); builtInMethods.Add(builtIn); } } @@ -455,6 +455,7 @@ public class ClassMirror : StaticMirror //} public ClassMirror(ProtoCore.Type type, ProtoCore.Core core) + : base(core) { if (core != null) { @@ -686,7 +687,7 @@ public List GetConstructors() foreach (ProcedureNode pNode in procList) { if (pNode.isConstructor == true) - constructors.Add(new MethodMirror(pNode)); + constructors.Add(new MethodMirror(pNode, staticCore)); } return constructors; @@ -722,7 +723,7 @@ public List GetFunctions() name = pNode.name; if (!pNode.isAssocOperator && !pNode.isAutoGenerated && !pNode.isAutoGeneratedThisProc && !pNode.isConstructor) { - methods.Add(new MethodMirror(pNode)); + methods.Add(new MethodMirror(pNode, staticCore)); } } @@ -755,7 +756,7 @@ public List GetOverloads(string methodName) name = pNode.name; if (name == methodName) { - methods.Add(new MethodMirror(pNode)); + methods.Add(new MethodMirror(pNode, staticCore)); } } @@ -808,7 +809,7 @@ public ProtoCore.Type? ReturnType private ProcedureNode procNode; - internal MethodMirror(ProcedureNode procNode) + internal MethodMirror(ProcedureNode procNode, ProtoCore.Core core) : base(core) { MethodName = procNode.name; IsConstructor = procNode.isConstructor; @@ -851,7 +852,23 @@ public List GetArgumentNames() return argTypes; } - + /// + /// Returns the Class of which the given method is a member + /// or null if it's a global function + /// + /// + public ClassMirror GetClass() + { + Validity.Assert(procNode != null); + int classScope = procNode.classScope; + if (classScope == Constants.kGlobalScope) + return null; + + ProtoCore.DSASM.ClassTable classTable = staticCore.ClassTable; + ClassNode classNode = classTable.ClassNodes[classScope]; + LibraryMirror libraryMirror = new LibraryMirror(classNode.ExternLib, staticCore); + return new ClassMirror(staticCore, classNode, libraryMirror); + } } public class PropertyMirror : StaticMirror @@ -977,7 +994,7 @@ public List GetGlobalMethods() for (int i = numBuiltInMethods; i < procNodes.Count; ++i) { - MethodMirror method = new MethodMirror(procNodes[i]); + MethodMirror method = new MethodMirror(procNodes[i], staticCore); methods.Add(method); } diff --git a/UIs/DesignScriptRunner/LiveRunnerWrapper.h b/UIs/DesignScriptRunner/LiveRunnerWrapper.h index c4e9efa..7e0edbb 100644 --- a/UIs/DesignScriptRunner/LiveRunnerWrapper.h +++ b/UIs/DesignScriptRunner/LiveRunnerWrapper.h @@ -3,7 +3,6 @@ #include "WrapperObject.h" using namespace ProtoScript::Runners; -using namespace GraphToDSCompiler; using namespace ProtoCore::AST::AssociativeAST; using namespace System::Collections::Generic; diff --git a/UIs/DesignScriptRunner/MirrorObjectWrapper.h b/UIs/DesignScriptRunner/MirrorObjectWrapper.h index 70b7802..8be6143 100644 --- a/UIs/DesignScriptRunner/MirrorObjectWrapper.h +++ b/UIs/DesignScriptRunner/MirrorObjectWrapper.h @@ -1,5 +1,6 @@ #pragma once #include "WrapperObject.h" +#include "StringUtils.h" using namespace ProtoCore::Mirror; @@ -68,7 +69,7 @@ class MethodMirrorWrapper : public WrapperObject getArgumentNames() const; - virtual std::vector getArgumentTypes(ProtoCore::Core^ core) const; - + std::vector getArgumentNames() const; + std::vector getArgumentTypes(ProtoCore::Core^ core) const; + }; \ No newline at end of file