本文整理匯總了C#中ProtoCore.AST.AssociativeAST.VarDeclNode類的典型用法代碼示例。如果您正苦於以下問題:C# VarDeclNode類的具體用法?C# VarDeclNode怎麽用?C# VarDeclNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VarDeclNode類屬於ProtoCore.AST.AssociativeAST命名空間,在下文中一共展示了VarDeclNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ArgumentSignatureNode
public ArgumentSignatureNode(ArgumentSignatureNode rhs)
: base(rhs)
{
Arguments = new List<VarDeclNode>();
foreach (VarDeclNode aNode in rhs.Arguments)
{
VarDeclNode newNode = new VarDeclNode(aNode);
Arguments.Add(newNode);
}
}
示例2: GenerateBuiltInMethodSignatureNode
private static ProtoCore.AST.AssociativeAST.FunctionDefinitionNode GenerateBuiltInMethodSignatureNode(ProtoCore.Lang.BuiltInMethods.BuiltInMethod method)
{
ProtoCore.AST.AssociativeAST.FunctionDefinitionNode fDef = new ProtoCore.AST.AssociativeAST.FunctionDefinitionNode();
fDef.Name = ProtoCore.Lang.BuiltInMethods.GetMethodName(method.ID);
fDef.ReturnType = method.ReturnType;
fDef.IsExternLib = true;
fDef.IsBuiltIn = true;
fDef.BuiltInMethodId = method.ID;
fDef.Signature = new ProtoCore.AST.AssociativeAST.ArgumentSignatureNode();
fDef.MethodAttributes = method.MethodAttributes;
foreach (KeyValuePair<string, ProtoCore.Type> param in method.Parameters)
{
ProtoCore.AST.AssociativeAST.VarDeclNode arg = new ProtoCore.AST.AssociativeAST.VarDeclNode();
arg.NameNode = new ProtoCore.AST.AssociativeAST.IdentifierNode { Name = param.Key, Value = param.Key };
arg.ArgumentType = param.Value;
fDef.Signature.AddArgument(arg);
}
return fDef;
}
示例3: BuildArgumentInfoFromVarDeclNode
private ArgumentInfo BuildArgumentInfoFromVarDeclNode(VarDeclNode argNode)
{
var argumentName = String.Empty;
ProtoCore.AST.Node defaultExpression = null;
if (argNode.NameNode is IdentifierNode)
{
argumentName = (argNode.NameNode as IdentifierNode).Value;
}
else if (argNode.NameNode is BinaryExpressionNode)
{
var bNode = argNode.NameNode as BinaryExpressionNode;
defaultExpression = bNode;
argumentName = (bNode.LeftNode as IdentifierNode).Value;
}
else
{
Validity.Assert(false, "Check generated AST");
}
var argInfo = new ProtoCore.DSASM.ArgumentInfo
{
Name = argumentName,
DefaultExpression = defaultExpression,
Attributes = argNode.ExternalAttributes
};
return argInfo;
}
示例4: EmitClassDeclNode
//.........這裏部分代碼省略.........
EmitMemberVariables(classDecl, graphNode);
}
else if (ProtoCore.CompilerDefinitions.Associative.CompilePass.kClassMemFuncSig == compilePass)
{
// Class member variable pass
// Populating each class entry vtables with their respective
// member variables signatures
globalClassIndex = core.ClassTable.GetClassId(classDecl.ClassName);
List<AssociativeNode> thisPtrOverloadList = new List<AssociativeNode>();
foreach (AssociativeNode funcdecl in classDecl.Procedures)
{
DfsTraverse(funcdecl, ref inferedType);
var funcDef = funcdecl as FunctionDefinitionNode;
if (funcDef == null || funcDef.IsStatic || funcDef.Name == ProtoCore.DSDefinitions.Keyword.Dispose)
continue;
bool isGetterSetter = CoreUtils.IsGetterSetter(funcDef.Name);
var thisPtrArgName = Constants.kThisPointerArgName;
if (!isGetterSetter)
{
var classsShortName = classDecl.ClassName.Split('.').Last();
var typeDepName = classsShortName.ToLower();
if (typeDepName != classsShortName && funcDef.Signature.Arguments.All(a => a.NameNode.Name != typeDepName))
thisPtrArgName = typeDepName;
}
// This is a function, create its parameterized this pointer overload
ThisPointerProcOverload thisProc = new ThisPointerProcOverload();
thisProc.classIndex = globalClassIndex;
thisProc.procNode = new FunctionDefinitionNode(funcDef);
var thisPtrArg = new VarDeclNode()
{
Access = ProtoCore.CompilerDefinitions.AccessModifier.kPublic,
NameNode = AstFactory.BuildIdentifier(thisPtrArgName),
ArgumentType = new ProtoCore.Type { Name = classDecl.ClassName, UID = globalClassIndex, rank = 0 }
};
thisProc.procNode.Signature.Arguments.Insert(0, thisPtrArg);
thisProc.procNode.IsAutoGeneratedThisProc = true;
if (CoreUtils.IsGetterSetter(funcDef.Name))
{
InsertThisPointerAtBody(thisProc);
}
else
{
// Generate a static function for member function f():
// satic def f(a: A)
// {
// return = a.f()
// }
thisProc.procNode.IsStatic = true;
BuildThisFunctionBody(thisProc);
}
thisPtrOverloadList.Add(thisProc.procNode);
}
foreach (var overloadFunc in thisPtrOverloadList)
{
// Emit the newly defined overloads
DfsTraverse(overloadFunc, ref inferedType);
}
示例5: EmitSetterFunction
private FunctionDefinitionNode EmitSetterFunction(ProtoCore.DSASM.SymbolNode prop, ProtoCore.Type argType)
{
var argument = new ProtoCore.AST.AssociativeAST.VarDeclNode()
{
Access = ProtoCore.CompilerDefinitions.AccessModifier.kPublic,
NameNode =AstFactory.BuildIdentifier(Constants.kTempArg),
ArgumentType = argType
};
var argumentSingature = new ArgumentSignatureNode();
argumentSingature.AddArgument(argument);
FunctionDefinitionNode setter = new FunctionDefinitionNode
{
Name = ProtoCore.DSASM.Constants.kSetterPrefix + prop.name,
Signature = argumentSingature,
Pattern = null,
ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeNull, 0),
FunctionBody = new CodeBlockNode(),
IsExternLib = false,
IsDNI = false,
ExternLibName = null,
Access = prop.access,
IsStatic = prop.isStatic,
IsAutoGenerated = true
};
// property = %tmpArg
var propIdent = new TypedIdentifierNode();
propIdent.Name = propIdent.Value = prop.name;
propIdent.datatype = prop.datatype;
var tmpArg =AstFactory.BuildIdentifier(Constants.kTempArg);
var assignment = AstFactory.BuildBinaryExpression(propIdent, tmpArg, Operator.assign);
setter.FunctionBody.Body.Add(assignment);
// return = null;
var returnNull = AstFactory.BuildReturnStatement(new NullNode());
setter.FunctionBody.Body.Add(returnNull);
return setter;
}
示例6: definitions
/*
1 Copy user-defined function definitions (excluding constructors) into a temp
2 Modify its signature to include an additional this pointer as the first argument.
The 'this' argument should take the type of the current class being traversed and be the first argument in the function.
The function name must be name mangled in order to stay unique
3 Append this temp to the current vtable
*/
private void InsertThisPointerArg(ThisPointerProcOverload procOverload)
{
// Modify its signature to include an additional this pointer as the first argument.
// The 'this' argument should take the type of the current class being traversed and be the first argument in the function.
// The function name must be name mangled in order to stay unique
ProtoCore.AST.AssociativeAST.FunctionDefinitionNode procNode = procOverload.procNode;
string className = compileStateTracker.ClassTable.ClassNodes[procOverload.classIndex].name;
string thisPtrArgName = ProtoCore.DSASM.Constants.kThisPointerArgName;
ProtoCore.AST.AssociativeAST.IdentifierNode ident = new ProtoCore.AST.AssociativeAST.IdentifierNode();
ident.Name = ident.Value = thisPtrArgName;
VarDeclNode thisPtrArg = new ProtoCore.AST.AssociativeAST.VarDeclNode()
{
memregion = ProtoCore.DSASM.MemoryRegion.kMemStack,
access = ProtoCore.DSASM.AccessSpecifier.kPublic,
NameNode = ident,
ArgumentType = new ProtoCore.Type { Name = className, UID = procOverload.classIndex, IsIndexable = false, rank = 0 }
};
procNode.Singnature.Arguments.Insert(0, thisPtrArg);
ProtoCore.Type type = new ProtoCore.Type();
}
示例7: BuildArgumentTypeFromVarDeclNode
private ProtoCore.Type BuildArgumentTypeFromVarDeclNode(VarDeclNode argNode)
{
Validity.Assert(argNode != null);
if (argNode == null)
{
return new ProtoCore.Type();
}
int uid = compileStateTracker.TypeSystem.GetType(argNode.ArgumentType.Name);
if (uid == (int)PrimitiveType.kInvalidType && !compileStateTracker.IsTempVar(argNode.NameNode.Name))
{
string message = String.Format(ProtoCore.BuildData.WarningMessage.kArgumentTypeUndefined, argNode.ArgumentType.Name, argNode.NameNode.Name);
buildStatus.LogWarning(ProtoCore.BuildData.WarningID.kTypeUndefined, message, compileStateTracker.CurrentDSFileName, argNode.line, argNode.col);
}
bool isArray = argNode.ArgumentType.IsIndexable;
int rank = argNode.ArgumentType.rank;
return compileStateTracker.TypeSystem.BuildTypeObject(uid, isArray, rank);
}
示例8: ParseArgumentDeclaration
private ProtoCore.AST.AssociativeAST.VarDeclNode ParseArgumentDeclaration(string parameterName, Type parameterType)
{
ProtoCore.AST.AssociativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.AssociativeAST.VarDeclNode();
varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;
varDeclNode.access = ProtoCore.Compiler.AccessSpecifier.kPublic;
ProtoCore.AST.AssociativeAST.IdentifierNode identifierNode = new ProtoCore.AST.AssociativeAST.IdentifierNode
{
Value = parameterName,
Name = parameterName,
datatype = ProtoCore.TypeSystem.BuildPrimitiveTypeObject(ProtoCore.PrimitiveType.kTypeVar, 0)
};
//Lets emit native DS type object
ProtoCore.Type argtype = CLRModuleType.GetProtoCoreType(parameterType, Module);
varDeclNode.NameNode = identifierNode;
varDeclNode.ArgumentType = argtype;
return varDeclNode;
}
示例9: BuildParamNode
public static VarDeclNode BuildParamNode(string paramName)
{
VarDeclNode param = new VarDeclNode();
param.NameNode = BuildIdentifier(paramName);
param.ArgumentType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, false);
return param;
}
示例10: 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;
}
示例11: 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++;
//}
}
示例12: Associative_ArgDecl
void Associative_ArgDecl(out ProtoCore.AST.AssociativeAST.AssociativeNode node, ProtoCore.DSASM.AccessSpecifier access = ProtoCore.DSASM.AccessSpecifier.kPublic)
{
ProtoCore.AST.AssociativeAST.IdentifierNode tNode = null;
ProtoCore.AST.AssociativeAST.VarDeclNode varDeclNode = new ProtoCore.AST.AssociativeAST.VarDeclNode();
varDeclNode.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;
varDeclNode.access = access;
Expect(1);
if (IsKeyWord(t.val, true))
{
errors.SemErr(t.line, t.col, String.Format("\"{0}\" is a keyword, identifier expected", t.val));
}
tNode = ProtoCore.Utils.CoreUtils.BuildAssocIdentifier(core, 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 == 48) {
Get();
Expect(1);
argtype.Name = t.val;
if (la.kind == 7) {
argtype.IsIndexable = true;
Get();
Expect(8);
argtype.rank = 1;
if (la.kind == 7 || la.kind == 21) {
if (la.kind == 21) {
Get();
Expect(7);
Expect(8);
argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 7) {
Get();
Expect(8);
argtype.rank++;
}
}
}
}
}
varDeclNode.ArgumentType = argtype;
node = varDeclNode;
}
示例13: Associative_vardecl
void Associative_vardecl(out ProtoCore.AST.AssociativeAST.AssociativeNode node, ProtoCore.DSASM.AccessSpecifier access = ProtoCore.DSASM.AccessSpecifier.kPublic, 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.memregion = ProtoCore.DSASM.MemoryRegion.kMemStack;
varDeclNode.access = access;
varDeclNode.Attributes = attrs;
varDeclNode.IsStatic = isStatic;
Expect(1);
if (IsKeyWord(t.val, true))
{
errors.SemErr(t.line, t.col, String.Format("\"{0}\" is a keyword, identifier expected", t.val));
}
NodeUtils.SetNodeLocation(varDeclNode, t);
tNode = ProtoCore.Utils.CoreUtils.BuildAssocIdentifier(core, t.val);
NodeUtils.SetNodeLocation(tNode, t);
varDeclNode.NameNode = tNode;
if (la.kind == 48) {
Get();
Expect(1);
ProtoCore.Type argtype = new ProtoCore.Type(); argtype.Name = t.val; argtype.rank = 0;
if (la.kind == 7) {
argtype.IsIndexable = true;
Get();
Expect(8);
argtype.rank = 1;
if (la.kind == 7 || la.kind == 21 || la.kind == 47) {
if (la.kind == 21) {
Get();
Expect(7);
Expect(8);
argtype.rank = ProtoCore.DSASM.Constants.nDimensionArrayRank;
} else {
while (la.kind == 7) {
Get();
Expect(8);
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 == 47) {
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++;
//}
}
示例14: AddArgument
public void AddArgument(VarDeclNode arg)
{
Arguments.Add(arg);
}
示例15: VarDeclNode
public VarDeclNode(VarDeclNode rhs)
: base(rhs)
{
Attributes = new List<AssociativeNode>();
foreach (AssociativeNode aNode in rhs.Attributes)
{
AssociativeNode newNode = NodeUtils.Clone(aNode);
Attributes.Add(newNode);
}
memregion = rhs.memregion;
ArgumentType = new ProtoCore.Type
{
UID = rhs.ArgumentType.UID,
rank = rhs.ArgumentType.rank,
IsIndexable = rhs.ArgumentType.IsIndexable,
Name = rhs.ArgumentType.Name
};
NameNode = NodeUtils.Clone(rhs.NameNode);
access = rhs.access;
IsStatic = rhs.IsStatic;
}