Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GetClass API to MethodMirror, changed access specifiers to AstCode... #170

Open
wants to merge 1 commit into
base: StableBranchWithTestcases
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions Core/GraphToDSCompiler/AstCodeBlockTraverse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ public class AstCodeBlockTraverse
/// </summary>
protected ProtoCore.AST.AssociativeAST.BinaryExpressionNode ChildTree { get; set; }

public AstCodeBlockTraverse(List<ProtoCore.AST.AssociativeAST.AssociativeNode> 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;
Expand All @@ -42,6 +40,12 @@ protected void EmitIdentifierNode(ref ProtoCore.AST.AssociativeAST.AssociativeNo
}
}

//=======================

/// <summary>
/// Depth first traversal of an AST node
/// </summary>
/// <param name="node"></param>
public void DFSTraverse(ref ProtoCore.AST.AssociativeAST.AssociativeNode node)
{
if (node is ProtoCore.AST.AssociativeAST.IdentifierNode)
Expand Down Expand Up @@ -110,13 +114,6 @@ public void DFSTraverse(ref ProtoCore.AST.AssociativeAST.AssociativeNode node)

}

//=======================

/// <summary>
/// Depth first traversal of an AST node
/// </summary>
/// <param name="node"></param>

/// <summary>
/// These functions emit the DesignScript code on the destination stream
/// </summary>
Expand All @@ -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++)
{
Expand Down Expand Up @@ -184,6 +181,7 @@ protected virtual void EmitFunctionCallNode(ref ProtoCore.AST.AssociativeAST.Fun
funcCallNode.FormalArguments[n] = argNode;
if (n + 1 < funcCallNode.FormalArguments.Count)
{

}
}
}
Expand Down
33 changes: 25 additions & 8 deletions Core/ProtoCore/Reflection/Mirror.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ protected static MethodMirror FindMethod(string methodName, List<ProtoCore.Type>
}
}
if (isEqual)
return new MethodMirror(procNode);
return new MethodMirror(procNode, staticCore);
}
}
}
Expand All @@ -389,7 +389,7 @@ private static List<MethodMirror> 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);
}
}
Expand Down Expand Up @@ -455,6 +455,7 @@ public class ClassMirror : StaticMirror
//}

public ClassMirror(ProtoCore.Type type, ProtoCore.Core core)
: base(core)
{
if (core != null)
{
Expand Down Expand Up @@ -686,7 +687,7 @@ public List<MethodMirror> GetConstructors()
foreach (ProcedureNode pNode in procList)
{
if (pNode.isConstructor == true)
constructors.Add(new MethodMirror(pNode));
constructors.Add(new MethodMirror(pNode, staticCore));
}

return constructors;
Expand Down Expand Up @@ -722,7 +723,7 @@ public List<MethodMirror> GetFunctions()
name = pNode.name;
if (!pNode.isAssocOperator && !pNode.isAutoGenerated && !pNode.isAutoGeneratedThisProc && !pNode.isConstructor)
{
methods.Add(new MethodMirror(pNode));
methods.Add(new MethodMirror(pNode, staticCore));
}
}

Expand Down Expand Up @@ -755,7 +756,7 @@ public List<MethodMirror> GetOverloads(string methodName)
name = pNode.name;
if (name == methodName)
{
methods.Add(new MethodMirror(pNode));
methods.Add(new MethodMirror(pNode, staticCore));
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -851,7 +852,23 @@ public List<string> GetArgumentNames()
return argTypes;
}


/// <summary>
/// Returns the Class of which the given method is a member
/// or null if it's a global function
/// </summary>
/// <returns></returns>
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
Expand Down Expand Up @@ -977,7 +994,7 @@ public List<MethodMirror> 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);
}

Expand Down
1 change: 0 additions & 1 deletion UIs/DesignScriptRunner/LiveRunnerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "WrapperObject.h"

using namespace ProtoScript::Runners;
using namespace GraphToDSCompiler;
using namespace ProtoCore::AST::AssociativeAST;
using namespace System::Collections::Generic;

Expand Down
7 changes: 4 additions & 3 deletions UIs/DesignScriptRunner/MirrorObjectWrapper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "WrapperObject.h"
#include "StringUtils.h"

using namespace ProtoCore::Mirror;

Expand Down Expand Up @@ -68,7 +69,7 @@ class MethodMirrorWrapper : public WrapperObject<MethodMirror, DesignScriptMetho

virtual const wchar_t* name() const;
virtual bool isConstructor() const;
virtual std::vector<const wchar_t*> getArgumentNames() const;
virtual std::vector<DesignScriptClass*> getArgumentTypes(ProtoCore::Core^ core) const;
std::vector<const wchar_t*> getArgumentNames() const;
std::vector<DesignScriptClass*> getArgumentTypes(ProtoCore::Core^ core) const;

};