本文整理汇总了C#中ProtoCore.Type类的典型用法代码示例。如果您正苦于以下问题:C# ProtoCore.Type类的具体用法?C# ProtoCore.Type怎么用?C# ProtoCore.Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProtoCore.Type类属于命名空间,在下文中一共展示了ProtoCore.Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SymbolNode
public SymbolNode(
string name,
int index,
int functionIndex,
Type datatype,
bool isArgument,
int runtimeIndex,
MemoryRegion memregion = MemoryRegion.InvalidRegion,
int scope = -1,
CompilerDefinitions.AccessModifier access = CompilerDefinitions.AccessModifier.Public,
bool isStatic = false,
int codeBlockId = Constants.kInvalidIndex)
{
this.name = name;
isTemp = name.StartsWith("%");
isSSATemp = name.StartsWith(Constants.kSSATempPrefix);
this.index = index;
this.functionIndex = functionIndex;
this.absoluteFunctionIndex = functionIndex;
this.datatype = datatype;
this.isArgument = isArgument;
this.memregion = memregion;
this.classScope = scope;
this.absoluteClassScope = scope;
runtimeTableIndex = runtimeIndex;
this.access = access;
this.isStatic = isStatic;
this.codeBlockId = codeBlockId;
}
开发者ID:sh4nnongoh,项目名称:Dynamo,代码行数:29,代码来源:SymbolTable.cs
示例2: DescriptionTest
public void DescriptionTest()
{
var assembly = System.Reflection.Assembly.UnsafeLoadFrom("FFITarget.dll");
var testClass = assembly.GetType("FFITarget.DummyZeroTouchClass");
MethodInfo methodWithDesc = testClass.GetMethod("FunctionWithDescription");
MethodInfo methodWithoutDesc = testClass.GetMethod("FunctionWithoutDescription");
NodeDescriptionAttribute atr = new NodeDescriptionAttribute("");
IEnumerable<TypedParameter> arguments;
FunctionDescriptor fucDescriptor;
// 1 case. Method with description.
var attributes = methodWithDesc.GetCustomAttributes(typeof(NodeDescriptionAttribute), false);
Assert.IsNotNull(attributes);
Assert.Greater(attributes.Length, 0);
atr = attributes[0] as NodeDescriptionAttribute;
arguments = methodWithDesc.GetParameters().Select(
arg =>
{
var type = new ProtoCore.Type();
type.Name = arg.ParameterType.ToString();
return new TypedParameter(arg.Name, type);
});
fucDescriptor = new FunctionDescriptor(new FunctionDescriptorParams
{
FunctionName = methodWithDesc.Name,
Summary = atr.ElementDescription,
Parameters = arguments
});
NodeModel node = new DSFunction(fucDescriptor);
Assert.AreEqual(atr.ElementDescription + "\n\n" + fucDescriptor.Signature, node.Description);
// 2 case. Method without description.
atr = new NodeDescriptionAttribute("");
attributes = methodWithoutDesc.GetCustomAttributes(typeof(NodeDescriptionAttribute), false);
Assert.IsNotNull(attributes);
Assert.AreEqual(attributes.Length, 0);
arguments = methodWithoutDesc.GetParameters().Select(
arg =>
{
var type = new ProtoCore.Type();
type.Name = arg.ParameterType.ToString();
return new TypedParameter(arg.Name, type);
});
fucDescriptor = new FunctionDescriptor(new FunctionDescriptorParams
{
FunctionName = methodWithDesc.Name,
Summary = atr.ElementDescription,
Parameters = arguments
});
node = new DSFunction(fucDescriptor);
Assert.AreEqual(fucDescriptor.Signature, node.Description);
}
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:58,代码来源:TestZeroTouchClass.cs
示例3: CLRFFIFunctionPointer
public CLRFFIFunctionPointer(CLRDLLModule module, string name, MemberInfo info, List<ProtoCore.Type> argTypes, ProtoCore.Type returnType)
{
Module = module;
Name = name;
ReflectionInfo = FFIMemberInfo.CreateFrom(info);
if (argTypes == null)
mArgTypes = GetArgumentTypes(ReflectionInfo);
else
mArgTypes = argTypes.ToArray();
mReturnType = returnType;
}
开发者ID:seasailor,项目名称:designscript,代码行数:13,代码来源:CLRFFIFunctionPointer.cs
示例4: SymbolNode
public SymbolNode(
string name,
int index,
int heapIndex,
int functionIndex,
ProtoCore.Type datatype,
ProtoCore.Type enforcedType,
int size,
int datasize,
bool isArgument,
int runtimeIndex,
MemoryRegion memregion = MemoryRegion.kInvalidRegion,
bool isArray = false,
List<int> arraySizeList = null,
int scope = -1,
ProtoCore.CompilerDefinitions.AccessModifier access = ProtoCore.CompilerDefinitions.AccessModifier.kPublic,
bool isStatic = false,
int codeBlockId = ProtoCore.DSASM.Constants.kInvalidIndex)
{
this.name = name;
isTemp = name.StartsWith("%");
this.index = index;
this.functionIndex = functionIndex;
this.absoluteFunctionIndex = functionIndex;
this.datatype = datatype;
this.staticType = enforcedType;
this.size = size;
this.datasize = datasize;
this.isArgument = isArgument;
this.arraySizeList = arraySizeList;
this.memregion = memregion;
this.classScope = scope;
this.absoluteClassScope = scope;
runtimeTableIndex = runtimeIndex;
this.access = access;
this.isStatic = isStatic;
this.codeBlockId = codeBlockId;
}
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:38,代码来源:SymbolTable.cs
示例5: PInvokeFunctionPointer
public PInvokeFunctionPointer(PInvokeDLLModule module, String name, ProtoCore.Type returnType)
{
Module = module;
Name = name;
mReturnType = returnType;
//mFunction = new FFICppFunction(module.Name, name);
mFunction = new FFICppFunction(module.ModuleBuilder, module.AssemblyName, module.AssemblyBuilder, name);
}
开发者ID:qingemeng,项目名称:Dynamo,代码行数:8,代码来源:PInvokeFFI.cs
示例6: ProcessDynamicFunction
private bool ProcessDynamicFunction(Instruction instr)
{
int fptr = ProtoCore.DSASM.Constants.kInvalidIndex;
int functionDynamicIndex = (int)instr.op1.opdata;
int classIndex = (int)instr.op2.opdata;
int depth = (int)instr.op3.opdata;
bool isDotMemFuncBody = functionDynamicIndex == ProtoCore.DSASM.Constants.kInvalidIndex;
bool isFunctionPointerCall = false;
if (isDotMemFuncBody)
{
functionDynamicIndex = (int)rmem.Pop().opdata;
}
DSASM.DynamicFunctionNode dynamicFunctionNode = core.DynamicFunctionTable.functionTable[functionDynamicIndex];
if (isDotMemFuncBody)
{
classIndex = dynamicFunctionNode.classIndex;
}
string procName = dynamicFunctionNode.functionName;
List<ProtoCore.Type> arglist = dynamicFunctionNode.argList;
if (procName == ProtoCore.DSASM.Constants.kFunctionPointerCall && depth == 0)
{
isFunctionPointerCall = true;
classIndex = ProtoCore.DSASM.Constants.kGlobalScope;
StackValue fpSv = rmem.Pop();
if (fpSv.optype != AddressType.FunctionPointer)
{
rmem.Pop(arglist.Count); //remove the arguments
return false;
}
fptr = (int)fpSv.opdata;
}
//retrieve the function arguments
List<StackValue> argSvList = new List<StackValue>();
if (isDotMemFuncBody)
{
arglist = new List<Type>();
StackValue argArraySv = rmem.Pop();
for (int i = 0; i < ArrayUtils.GetElementSize(argArraySv, core); ++i)
{
StackValue sv = core.Heap.Heaplist[(int)argArraySv.opdata].Stack[i];
argSvList.Add(sv); //actual arguments
ProtoCore.Type paramType = new ProtoCore.Type();
paramType.UID = (int)sv.metaData.type;
paramType.rank = 0;
if (sv.optype == AddressType.ArrayPointer)
{
StackValue paramSv = sv;
while (paramSv.optype == AddressType.ArrayPointer)
{
paramType.rank++;
int arrayHeapPtr = (int)paramSv.opdata;
if (core.Heap.Heaplist[arrayHeapPtr].VisibleSize > 0)
{
paramSv = core.Heap.Heaplist[arrayHeapPtr].Stack[0];
paramType.UID = (int)paramSv.metaData.type;
}
else
{
paramType.UID = (int)ProtoCore.PrimitiveType.kTypeArray;
break;
}
}
}
arglist.Add(paramType); //build arglist
}
argSvList.Reverse();
}
else
{
for (int i = 0; i < arglist.Count; i++)
{
StackValue argSv = rmem.Pop();
argSvList.Add(argSv);
}
}
int lefttype = DSASM.Constants.kGlobalScope;
bool isLeftClass = false;
if (isDotMemFuncBody && rmem.Stack.Last().optype == AddressType.Int) //constructor or static function
{
//in this case, ptr won't be used
lefttype = (int)rmem.Pop().opdata;
isLeftClass = true;
}
else if (depth > 0)
{
//resolve the identifier list
StackValue pSv = GetFinalPointer(depth);
//push the resolved stack value to stack
rmem.Push(pSv);
lefttype = (int)pSv.metaData.type;
}
int type = lefttype;
//.........这里部分代码省略.........
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:101,代码来源:Executive.cs
示例7: Associative_DecoratedIdentifier
void Associative_DecoratedIdentifier(out ProtoCore.AST.AssociativeAST.AssociativeNode node)
{
node = null;
if (IsTypedVariable()) {
Expect(1);
if (IsKeyWord(t.val, true))
{
errors.SemErr(t.line, t.col, String.Format("\"{0}\" is a keyword, identifier expected", t.val));
}
var typedVar = new ProtoCore.AST.AssociativeAST.TypedIdentifierNode();
typedVar.Name = typedVar.Value = t.val;
NodeUtils.SetNodeLocation(typedVar, t);
Expect(48);
Expect(1);
int type = core.TypeSystem.GetType(t.val);
if (type == ProtoCore.DSASM.Constants.kInvalidIndex)
{
var unknownType = new ProtoCore.Type();
unknownType.UID = ProtoCore.DSASM.Constants.kInvalidIndex;
unknownType.Name = t.val;
typedVar.datatype = unknownType;
}
else
{
typedVar.datatype = core.TypeSystem.BuildTypeObject(type, false, 0);
}
if (la.kind == 7) {
var datatype = typedVar.datatype;
Get();
Expect(8);
datatype.rank = 1;
if (la.kind == 7 || la.kind == 21) {
if (la.kind == 21) {
Get();
Expect(7);
Expect(8);
datatype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 7) {
Get();
Expect(8);
datatype.rank++;
}
}
}
typedVar.datatype = datatype;
}
node = typedVar;
} else if (la.kind == 1 || la.kind == 9 || la.kind == 44) {
Associative_IdentifierList(out node);
} else SynErr(94);
}
开发者ID:Benglin,项目名称:designscript,代码行数:54,代码来源:Parser.cs
示例8: BuildRealDependencyForIdentList
protected void BuildRealDependencyForIdentList(AssociativeGraph.GraphNode graphNode)
{
if (ssaPointerStack.Count == 0)
{
return;
}
// Push all dependent pointers
ProtoCore.AST.AssociativeAST.IdentifierListNode identList = BuildIdentifierList(ssaPointerStack.Peek());
// Comment Jun: perhaps this can be an assert?
if (null != identList)
{
ProtoCore.Type type = new ProtoCore.Type();
type.UID = globalClassIndex;
ProtoCore.AssociativeGraph.UpdateNodeRef nodeRef = new AssociativeGraph.UpdateNodeRef();
int functionIndex = globalProcIndex;
DFSGetSymbolList_Simple(identList, ref type, ref functionIndex, nodeRef);
if (null != graphNode && nodeRef.nodeList.Count > 0)
{
ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
dependentNode.updateNodeRefList.Add(nodeRef);
graphNode.PushDependent(dependentNode);
// If the pointerList is a setter, then it should also be in the lhs of a graphNode
// Given:
// a.x = 1
// Which was converted to:
// tvar = a.set_x(1)
// Set a.x as lhs of the graphnode.
// This means that statement that depends on a.x can re-execute, such as:
// p = a.x;
//
List<ProtoCore.AST.AssociativeAST.AssociativeNode> topList = ssaPointerStack.Peek();
string propertyName = topList[topList.Count - 1].Name;
bool isSetter = propertyName.StartsWith(Constants.kSetterPrefix);
if (isSetter)
{
graphNode.updateNodeRefList.Add(nodeRef);
graphNode.IsLHSIdentList = true;
AutoGenerateUpdateArgumentReference(nodeRef, graphNode);
}
}
}
}
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:47,代码来源:CodeGen.cs
示例9: functiondecl
void functiondecl(out Node node)
{
FunctionDefinitionNode funcDecl = new FunctionDefinitionNode();
ProtoCore.Type rtype = new ProtoCore.Type(); rtype.Name = "var"; rtype.UID = 0;
Expect(18);
Expect(1);
funcDecl.Name = t.val;
if (la.kind == 36) {
Get();
ReturnType(out rtype);
}
funcDecl.ReturnType = rtype;
Expect(8);
if (la.kind == 1 || la.kind == 25) {
ArgumentSignatureNode args = new ArgumentSignatureNode();
Node argdecl;
ArgDecl(out argdecl);
args.AddArgument(argdecl as VarDeclNode);
while (la.kind == 30) {
Get();
ArgDecl(out argdecl);
args.AddArgument(argdecl as VarDeclNode);
}
funcDecl.Signature = args;
}
Expect(9);
isGlobalScope = false;
Expect(32);
funcDecl.FunctionBody = new CodeBlockNode();
NodeList body = new NodeList();
stmtlist(out body);
Expect(33);
funcDecl.localVars = localVarCount;
funcDecl.FunctionBody.Body = body;
node = funcDecl;
isGlobalScope = true;
localVarCount= 0;
}
开发者ID:samuto,项目名称:designscript,代码行数:40,代码来源:Parser.cs
示例10: BuildRealDependencyForIdentList
protected void BuildRealDependencyForIdentList(AssociativeGraph.GraphNode graphNode)
{
// Push all dependent pointers
ProtoCore.AST.AssociativeAST.IdentifierListNode identList = BuildIdentifierList(ssaPointerList);
// Comment Jun: perhaps this can be an assert?
if (null != identList)
{
ProtoCore.Type type = new ProtoCore.Type();
type.UID = globalClassIndex;
ProtoCore.AssociativeGraph.UpdateNodeRef nodeRef = new AssociativeGraph.UpdateNodeRef();
int functionIndex = globalProcIndex;
DFSGetSymbolList_Simple(identList, ref type, ref functionIndex, nodeRef);
if (null != graphNode && nodeRef.nodeList.Count > 0)
{
ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
dependentNode.updateNodeRefList.Add(nodeRef);
graphNode.PushDependent(dependentNode);
}
}
}
开发者ID:khoaho,项目名称:Dynamo,代码行数:22,代码来源:CodeGen.cs
示例11: Imperative_ReturnType
void Imperative_ReturnType(out ProtoCore.Type type) {
ProtoCore.Type rtype = new ProtoCore.Type();
Expect(1);
rtype.Name = t.val; rtype.rank = 0;
if (la.kind == 10) {
Get();
Expect(11);
rtype.rank = 1;
if (la.kind == 10 || la.kind == 24) {
if (la.kind == 24) {
Get();
Expect(10);
Expect(11);
rtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 10) {
Get();
Expect(11);
rtype.rank++;
}
}
}
}
type = rtype;
}
开发者ID:limrzx,项目名称:Dynamo,代码行数:25,代码来源:Parser.cs
示例12: TestRoundTrip_FunctionDefAndCall_01
public void TestRoundTrip_FunctionDefAndCall_01()
{
//=================================
// 1. Build AST
// 2. Execute AST and verify
// 3. Convert AST to source
// 4. Execute source and verify
//=================================
int result1 = 20;
ExecutionMirror mirror = null;
// 1. Build the AST tree
// def foo()
// {
// b = 10;
// return = b + 10;
// }
//
// x = foo();
ProtoCore.AST.AssociativeAST.CodeBlockNode cbn = new ProtoCore.AST.AssociativeAST.CodeBlockNode();
// Build the function body
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assignment1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("b"),
new ProtoCore.AST.AssociativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
ProtoCore.AST.AssociativeAST.BinaryExpressionNode returnExpr = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("b"),
new ProtoCore.AST.AssociativeAST.IntNode(10),
ProtoCore.DSASM.Operator.add);
ProtoCore.AST.AssociativeAST.BinaryExpressionNode returnNode = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode(ProtoCore.DSDefinitions.Keyword.Return),
returnExpr,
ProtoCore.DSASM.Operator.assign);
cbn.Body.Add(assignment1);
cbn.Body.Add(returnNode);
// Build the function definition foo
const string functionName = "foo";
ProtoCore.AST.AssociativeAST.FunctionDefinitionNode funcDefNode = new ProtoCore.AST.AssociativeAST.FunctionDefinitionNode();
funcDefNode.Name = functionName;
funcDefNode.FunctionBody = cbn;
// Function Return type
ProtoCore.Type returnType = new ProtoCore.Type();
returnType.Initialize();
returnType.UID = (int)ProtoCore.PrimitiveType.Var;
returnType.Name = ProtoCore.DSDefinitions.Keyword.Var;
funcDefNode.ReturnType = returnType;
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(funcDefNode);
// Build the statement that calls the function foo
ProtoCore.AST.AssociativeAST.FunctionCallNode functionCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
functionCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode(functionName);
ProtoCore.AST.AssociativeAST.BinaryExpressionNode callstmt = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("x"),
functionCall,
ProtoCore.DSASM.Operator.assign);
astList.Add(callstmt);
// 2. Execute AST and verify
mirror = thisTest.RunASTSource(astList);
Assert.IsTrue((Int64)mirror.GetValue("x").Payload == result1);
// 3. Convert AST to source
ProtoCore.CodeGenDS codegenDS = new ProtoCore.CodeGenDS(astList);
string code = codegenDS.GenerateCode();
Console.WriteLine(code);
// 4. Execute source and verify
mirror = thisTest.RunScriptSource(code);
Assert.IsTrue((Int64)mirror.GetValue("x").Payload == result1);
}
开发者ID:limrzx,项目名称:Dynamo,代码行数:87,代码来源:RoundTripTests.cs
示例13: Imperative_decoratedIdentifier
void Imperative_decoratedIdentifier(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
node = null;
if (IsLocallyTypedVariable()) {
Expect(1);
if (IsKeyWord(t.val, true))
{
errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val));
}
var typedVar = new ProtoCore.AST.ImperativeAST.TypedIdentifierNode();
typedVar.Name = typedVar.Value = t.val;
NodeUtils.SetNodeLocation(typedVar, t);
Expect(47);
Expect(40);
typedVar.IsLocal = true;
Expect(1);
int type = core.TypeSystem.GetType(t.val);
if (type == ProtoCore.DSASM.Constants.kInvalidIndex)
{
var unknownType = new ProtoCore.Type();
unknownType.UID = ProtoCore.DSASM.Constants.kInvalidIndex;
unknownType.Name = t.val;
typedVar.DataType = unknownType;
}
else
{
typedVar.DataType = core.TypeSystem.BuildTypeObject(type, 0);
}
if (la.kind == 10) {
var datatype = typedVar.DataType;
Get();
Expect(11);
datatype.rank = 1;
if (la.kind == 10 || la.kind == 24) {
if (la.kind == 24) {
Get();
Expect(10);
Expect(11);
datatype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 10) {
Get();
Expect(11);
datatype.rank++;
}
}
}
typedVar.DataType = datatype;
}
node = typedVar;
} else if (IsLocalVariable()) {
Expect(1);
if (IsKeyWord(t.val, true))
{
errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val));
}
var identNode = new ProtoCore.AST.ImperativeAST.IdentifierNode();
identNode.Name = identNode.Value = t.val;
NodeUtils.SetNodeLocation(identNode, t);
Expect(47);
Expect(40);
identNode.IsLocal = true;
node = identNode;
} else if (IsTypedVariable()) {
Expect(1);
if (IsKeyWord(t.val, true))
{
errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val));
}
var typedVar = new ProtoCore.AST.ImperativeAST.TypedIdentifierNode();
typedVar.Name = typedVar.Value = t.val;
NodeUtils.SetNodeLocation(typedVar, t);
Expect(47);
Expect(1);
int type = core.TypeSystem.GetType(t.val);
if (type == ProtoCore.DSASM.Constants.kInvalidIndex)
{
var unknownType = new ProtoCore.Type();
unknownType.UID = ProtoCore.DSASM.Constants.kInvalidIndex;
unknownType.Name = t.val;
typedVar.DataType = unknownType;
}
else
{
typedVar.DataType = core.TypeSystem.BuildTypeObject(type, 0);
}
if (la.kind == 10) {
var datatype = typedVar.DataType;
Get();
Expect(11);
datatype.rank = 1;
if (la.kind == 10 || la.kind == 24) {
if (la.kind == 24) {
Get();
//.........这里部分代码省略.........
开发者ID:limrzx,项目名称:Dynamo,代码行数:101,代码来源:Parser.cs
示例14: Imperative_ArgDecl
void Imperative_ArgDecl(out ProtoCore.AST.ImperativeAST.ImperativeNode node) {
ProtoCore.AST.ImperativeAST.IdentifierNode tNode = null;
ProtoCore.AST.ImperativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.ImperativeAST.VarDeclNode();
NodeUtils.SetNodeLocation(varDeclNode, la);
varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.MemStack;
Expect(1);
if (IsKeyWord(t.val, true))
{
errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val));
}
tNode = BuildImperativeIdentifier(t.val);
NodeUtils.SetNodeLocation(tNode, t);
varDeclNode.NameNode = tNode;
NodeUtils.CopyNodeLocation(varDeclNode, tNode);
ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = "var"; argtype.rank = 0; argtype.UID = 0;
if (la.kind == 47) {
Get();
Expect(1);
argtype.Name = t.val;
if (la.kind == 10) {
Get();
Expect(11);
argtype.rank = 1;
if (la.kind == 10 || la.kind == 24) {
if (la.kind == 24) {
Get();
Expect(10);
Expect(11);
argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 10) {
Get();
Expect(11);
argtype.rank++;
}
}
}
}
}
varDeclNode.ArgumentType = argtype;
node = varDeclNode;
if(!isGlobalScope) {
localVarCount++;
}
}
开发者ID:limrzx,项目名称:Dynamo,代码行数:49,代码来源:Parser.cs
示例15: Associative_ClassReference
void Associative_ClassReference(out ProtoCore.Type type) {
type = new ProtoCore.Type();
string name;
Expect(1);
name = t.val;
type.Name = name;
type.UID = 0;
}
开发者ID:limrzx,项目名称:Dynamo,代码行数:8,代码来源:Parser.cs
示例16: Associative_ArgDecl
void Associative_ArgDecl(out ProtoCore.AST.AssociativeAST.AssociativeNode node, ProtoCore.CompilerDefinitions.AccessModifier access = ProtoCore.CompilerDefinitions.AccessModifier.Public) {
ProtoCore.AST.AssociativeAST.IdentifierNode tNode = null;
ProtoCore.AST.AssociativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.AssociativeAST.VarDeclNode();
varDeclNode.Access = access;
Expect(1);
if (IsKeyWord(t.val, true))
{
errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val));
}
tNode = AstFactory.BuildIdentifier(t.val);
NodeUtils.SetNodeLocation(tNode, t);
varDeclNode.NameNode = tNode;
NodeUtils.CopyNodeLocation(varDeclNode, tNode);
ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = "var"; argtype.rank = 0; argtype.UID = 0;
if (la.kind == 47) {
Get();
Expect(1);
argtype.Name = t.val;
if (la.kind == 10) {
Get();
Expect(11);
argtype.rank = 1;
if (la.kind == 10 || la.kind == 24) {
if (la.kind == 24) {
Get();
Expect(10);
Expect(11);
argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 10) {
Get();
Expect(11);
argtype.rank++;
}
}
}
}
}
varDeclNode.ArgumentType = argtype;
node = varDeclNode;
}
开发者ID:limrzx,项目名称:Dynamo,代码行数:43,代码来源:Parser.cs
示例17: Associative_vardecl
void Associative_vardecl(out ProtoCore.AST.AssociativeAST.AssociativeNode node, ProtoCore.CompilerDefinitions.AccessModifier access = ProtoCore.CompilerDefinitions.AccessModifier.Public, bool isStatic = false, List<ProtoCore.AST.AssociativeAST.AssociativeNode> attrs = null) {
ProtoCore.AST.AssociativeAST.IdentifierNode tNode = null;
ProtoCore.AST.AssociativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.AssociativeAST.VarDeclNode();
varDeclNode.Access = access;
varDeclNode.IsStatic = isStatic;
Expect(1);
if (IsKeyWord(t.val, true))
{
errors.SemErr(t.line, t.col, String.Format(Resources.keywordCantBeUsedAsIdentifier, t.val));
}
NodeUtils.SetNodeLocation(varDeclNode, t);
tNode = AstFactory.BuildIdentifier(t.val);
NodeUtils.SetNodeLocation(tNode, t);
varDeclNode.NameNode = tNode;
if (la.kind == 47) {
Get();
Expect(1);
ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = t.val; argtype.rank = 0;
if (la.kind == 10) {
Get();
Expect(11);
argtype.rank = 1;
if (la.kind == 10 || la.kind == 24 || la.kind == 51) {
if (la.kind == 24) {
Get();
Expect(10);
Expect(11);
argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 10) {
Get();
Expect(11);
argtype.rank++;
}
}
}
}
string oldName = tNode.Name;
string oldValue = tNode.Value;
// Here since the variable has an explicitly specified type
// the "IdentifierNode" should really be "TypedIdentifierNode"
// (which is used to indicate the identifier that has explicit
// type specified).
tNode = new ProtoCore.AST.AssociativeAST.TypedIdentifierNode()
{
Name = oldName,
Value = oldValue
};
argtype.UID = core.TypeSystem.GetType(argtype.Name);
tNode.datatype = argtype;
varDeclNode.NameNode = tNode;
varDeclNode.ArgumentType = argtype;
}
if (la.kind == 51) {
Get();
ProtoCore.AST.AssociativeAST.AssociativeNode rhsNode;
Associative_Expression(out rhsNode);
ProtoCore.AST.AssociativeAST.BinaryExpressionNode bNode = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode();
NodeUtils.CopyNodeLocation(bNode, varDeclNode);
bNode.LeftNode = tNode;
bNode.RightNode = rhsNode;
bNode.Optr = Operator.assign;
varDeclNode.NameNode = bNode;
}
node = varDeclNode;
//if(!isGlobalScope) {
// localVarCount++;
//}
}
开发者ID:limrzx,项目名称:Dynamo,代码行数:76,代码来源:Parser.cs
示例18: ReturnType
void ReturnType(out ProtoCore.Type type)
{
ProtoCore.Type rtype = new ProtoCore.Type();
Expect(1);
rtype.Name = t.val; rtype.rank = 0;
if (la.kind == 6) {
rtype.IsIndexable = true;
Get();
Expect(7);
rtype.rank = 1;
if (la.kind == 6 || la.kind == 17) {
if (la.kind == 17) {
Get();
Expect(6);
Expect(7);
rtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 6) {
Get();
Expect(7);
rtype.rank++;
}
}
}
}
type = rtype;
}
开发者ID:samuto,项目名称:designscript,代码行数:27,代码来源:Parser.cs
示例19: TestProtoASTExecute_ArrayIndex_RHS_Assign04
public void TestProtoASTExecute_ArrayIndex_RHS_Assign04()
{
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
// a = {1, 2, 3, 4};
int[] input = { 1, 2, 3, 4 };
ProtoCore.AST.AssociativeAST.BinaryExpressionNode declareNodeA = CreateDeclareArrayNode("a", input);
astList.Add(declareNodeA);
// b = 4;
ProtoCore.AST.AssociativeAST.BinaryExpressionNode declareNodeB = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("b"),
new ProtoCore.AST.AssociativeAST.IntNode(5),
ProtoCore.DSASM.Operator.assign);
astList.Add(declareNodeB);
// def foo(){
// return = -4;
// }
ProtoCore.AST.AssociativeAST.CodeBlockNode cbn = new ProtoCore.AST.AssociativeAST.CodeBlockNode();
ProtoCore.AST.AssociativeAST.BinaryExpressionNode returnNode = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode(ProtoCore.DSDefinitions.Keyword.Return),
new ProtoCore.AST.AssociativeAST.IntNode(-4),
ProtoCore.DSASM.Operator.assign);
cbn.Body.Add(returnNode);
// Build the function definition foo
const string functionName = "foo";
ProtoCore.AST.AssociativeAST.FunctionDefinitionNode funcDefNode = new ProtoCore.AST.AssociativeAST.FunctionDefinitionNode() {
Name = functionName,
FunctionBody = cbn };
// Function Return Type
ProtoCore.Type returnType = new ProtoCore.Type();
returnType.Initialize();
returnType.UID = (int)ProtoCore.PrimitiveType.Var;
returnType.Name = ProtoCore.DSDefinitions.Keyword.Var;
funcDefNode.ReturnType = returnType;
astList.Add(funcDefNode);
// c = a[b + foo()];
ProtoCore.AST.AssociativeAST.FunctionCallNode functionCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
functionCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode(functionName);
ProtoCore.AST.AssociativeAST.BinaryExpressionNode operation1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("b"),
functionCall,
ProtoCore.DSASM.Operator.add);
ProtoCore.AST.AssociativeAST.IdentifierNode nodeALHS = new ProtoCore.AST.AssociativeAST.IdentifierNode("a");
nodeALHS.ArrayDimensions = new ProtoCore.AST.AssociativeAST.ArrayNode {
Expr = operation1 };
ProtoCore.AST.AssociativeAST.BinaryExpressionNode nodeALHSAssignment = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("c"),
nodeALHS,
ProtoCore.DSASM.Operator.assign);
astList.Add(nodeALHSAssignment);
// Verify the results
ExecutionMirror mirror = thisTest.RunASTSource(astList);
Obj o = mirror.GetValue("c");
Console.WriteLine(o.Payload);
// expected: c = 2
Assert.AreEqual(2, Convert.ToInt32(o.Payload));
}
开发者ID:limrzx,项目名称:Dynamo,代码行数:69,代码来源:ProtoASTExecutionTests.cs
示例20: ArgDecl
void ArgDecl(out Node node)
{
IdentifierNode tNode = null;
VarDeclNode varDeclNode = new ProtoImperative.AST.VarDeclNode();
varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;
if (la.kind == 25) {
Get();
varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemHeap;
}
if (isArrayAccess()) {
arrayident(out node);
tNode = node as IdentifierNode;
varDeclNode.NameNode = tNode;
} else if (la.kind == 1) {
Get();
tNode = new IdentifierNode()
{
Value = t.val,
Name = t.val,
type = (int)ProtoCore.PrimitiveType.kTypeVar,
datatype = ProtoCore.PrimitiveType.kTypeVar
};
varDeclNode.NameNode = tNode;
} else SynErr(68);
ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = "var"; argtype.rank = 0; argtype.UID = 0;
if (la.kind == 36) {
Get();
Expect(1);
argtype.Name = t.val;
if (la.kind == 6) {
argtype.IsIndexable = true;
Get();
Expect(7);
argtype.rank = 1;
if (la.kind == 6 || la.kind == 17 || la.kind == 31) {
if (la.kind == 17) {
Get();
Expect(6);
Expect(7);
argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 6) {
Get();
Expect(7);
argtype.rank++;
}
}
}
}
}
varDeclNode.ArgumentType = argtype;
if (la.kind == 31) {
Get();
Node rhsNode;
expr(out rhsNode);
BinaryExpressionNode bNode = new BinaryExpressionNode();
bNode.LeftNode = tNode;
bNode.RightNode = rhsNode;
bNode.Optr = Operator.assign;
varDeclNode.NameNode = bNode;
}
node = varDeclNode;
if(!isGlobalScope) {
localVarCount++;
}
}
开发者ID:samuto,项目名称:designscript,代码行数:70,代码来源:Parser.cs
注:本文中的ProtoCore.Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论