public TypeParameterConstraintNode(AtomicNameNode typeParameter, ParseNodeList typeConstraints, bool hasConstructorConstraint) : base(ParseNodeType.ConstraintClause, typeParameter.Token) { this.typeParameter = typeParameter; this.typeConstraints = typeConstraints; this.hasConstructorConstraint = hasConstructorConstraint; }
public SwitchSectionNode(Token token, ParseNodeList labels, ParseNodeList statements) : base(ParseNodeType.SwitchSection, token) { Labels = GetParentedNodeList(labels); Statements = GetParentedNodeList(statements); }
public ConstantFieldDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, ParseNodeList initializers) : base(ParseNodeType.ConstFieldDeclaration, token, attributes, modifiers, type, initializers, false) { }
public SwitchNode(Token token, ParseNode condition, ParseNodeList cases) : base(ParseNodeType.Switch, token) { Condition = GetParentedNode(condition); Cases = GetParentedNodeList(cases); }
public FieldDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, ParseNodeList initializers, bool isFixed) : this(ParseNodeType.FieldDeclaration, token, attributes, modifiers, type, initializers, isFixed) { }
public NamespaceNode(Token token, string name, ParseNodeList usingClauses, ParseNodeList members) : base(ParseNodeType.Namespace, token) { Name = name; UsingClauses = GetParentedNodeList(usingClauses); Members = GetParentedNodeList(members); }
public DestructorDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, AtomicNameNode name, BlockStatementNode body) : base(ParseNodeType.DestructorDeclaration, token, attributes, modifiers, /* return type */ null, name, new ParseNodeList(), body) { }
public TryNode(Token token, ParseNode body, ParseNodeList catchClauses, ParseNode finallyClause) : base(ParseNodeType.Try, token) { Body = GetParentedNode(body); CatchClauses = GetParentedNodeList(catchClauses); FinallyClause = GetParentedNode(finallyClause); }
internal static string GetNodeTransformName(this ParseNodeList parseNodeList) { string dsharpMemberName = parseNodeList?.GetAttributeValue(DSharpStringResources.DSHARP_MEMBER_NAME_ATTRIBUTE); if (!string.IsNullOrEmpty(dsharpMemberName)) { return(DSharpStringResources.ScriptExportMember(dsharpMemberName)); } return(parseNodeList?.GetAttributeValue(DSharpStringResources.SCRIPT_ALIAS_ATTRIBUTE)); }
public NamespaceNode(Token token, NameNode nameNode, ParseNodeList externAliases, ParseNodeList usingClauses, ParseNodeList members) : base(ParseNodeType.Namespace, token) { Name = nameNode.Name; this.externAliases = GetParentedNodeList(externAliases); UsingClauses = GetParentedNodeList(usingClauses); Members = GetParentedNodeList(members); }
public AccessorNode(Token token, ParseNodeList attributes, AtomicNameNode name, BlockStatementNode body, Modifiers modifiers) : base(ParseNodeType.AccessorDeclaration, token) { this.name = (AtomicNameNode)GetParentedNode(name); Implementation = (BlockStatementNode)GetParentedNode(body); this.attributes = GetParentedNodeList(attributes); Modifiers = modifiers; }
public CompilationUnitNode(Token token, ParseNodeList externAliases, ParseNodeList usingClauses, ParseNodeList attributes, ParseNodeList members) : base(ParseNodeType.CompilationUnit, token) { this.externAliases = GetParentedNodeList(externAliases); UsingClauses = GetParentedNodeList(usingClauses); Attributes = GetParentedNodeList(attributes); Members = GetParentedNodeList(GetNamespaces(members)); }
public OperatorDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, TokenType operatorNodeType, ParseNode returnType, ParseNodeList formals, BlockStatementNode body) : base(ParseNodeType.OperatorDeclaration, token, attributes, modifiers, returnType, /* name */ null, formals, body) { OperatorTokenType = operatorNodeType; }
public IndexerDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, NameNode interfaceType, ParseNodeList parameters, AccessorNode get, AccessorNode set) : base(ParseNodeType.IndexerDeclaration, token, attributes, modifiers, type, interfaceType, get, set) { Parameters = GetParentedNodeList(parameters); }
private string GetAttributeValue(ParseNodeList attributes, string attributeName) { AttributeNode node = AttributeNode.FindAttribute(attributes, attributeName); if (node != null) { Debug.Assert(node.Arguments[0] is LiteralNode); Debug.Assert(((LiteralNode)node.Arguments[0]).Value is string); return((string)((LiteralNode)node.Arguments[0]).Value); } return(null); }
public PropertyDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, NameNode interfaceType, AtomicNameNode name, AccessorNode getOrRemove, AccessorNode setOrAdd) : this(ParseNodeType.PropertyDeclaration, token, attributes, modifiers, type, interfaceType, getOrRemove, setOrAdd) { NameNode = (AtomicNameNode)GetParentedNode(name); }
internal static string GetAttributeValue(this ParseNodeList parseNodeList, string attributeName) { AttributeNode node = AttributeNode.FindAttribute(parseNodeList, attributeName); if (node != null && node.Arguments.Count != 0 && node.Arguments[0].NodeType == ParseNodeType.Literal) { Debug.Assert(((LiteralNode)node.Arguments[0]).Value is string); return((string)((LiteralNode)node.Arguments[0]).Value); } return(null); }
public CustomTypeNode(Token token, TokenType type, ParseNodeList attributes, Modifiers modifiers, AtomicNameNode name, ParseNodeList typeParameters, ParseNodeList baseTypes, ParseNodeList constraintClauses, ParseNodeList members) : base(ParseNodeType.Type, token, type, attributes, modifiers, name, typeParameters, constraintClauses) { BaseTypes = GetParentedNodeList(baseTypes); Members = GetParentedNodeList(members); }
protected FieldDeclarationNode(ParseNodeType nodeType, Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, ParseNodeList initializers, bool isFixed) : base(nodeType, token) { Attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); Modifiers = modifiers; Type = GetParentedNode(type); Initializers = GetParentedNodeList(initializers); IsFixed = isFixed; }
public ConstructorDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, AtomicNameNode name, ParseNodeList formals, bool callBase, ParseNode baseArguments, BlockStatementNode body) : base(ParseNodeType.ConstructorDeclaration, token, attributes, modifiers, /* return type */ null, name, formals, body) { CallBase = callBase; BaseArguments = GetParentedNode(baseArguments); }
public DelegateTypeNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode returnType, AtomicNameNode name, ParseNodeList typeParameters, ParseNodeList parameters, ParseNodeList constraintClauses) : base(ParseNodeType.Delegate, token, TokenType.Delegate, attributes, modifiers, name, typeParameters, constraintClauses) { ReturnType = GetParentedNode(returnType); Parameters = GetParentedNodeList(parameters); }
public UserTypeNode(ParseNodeType type, Token token, TokenType tokenType, ParseNodeList attributes, Modifiers modifiers, AtomicNameNode name, ParseNodeList typeParameters, ParseNodeList constraintClauses) : base(type, token) { Type = tokenType; Attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); Modifiers = modifiers; nameNode = name; this.typeParameters = GetParentedNodeList(typeParameters); this.constraintClauses = GetParentedNodeList(constraintClauses); }
private string GetAssemblyScriptName(ParseNodeList compilationUnits) { foreach (CompilationUnitNode compilationUnit in compilationUnits) { foreach (AttributeBlockNode attribBlock in compilationUnit.Attributes) { string scriptName = GetAttributeValue(attribBlock.Attributes, "ScriptAssembly"); if (scriptName != null) { return(scriptName); } } } return(null); }
private string GetAssemblyScriptPrefix(ParseNodeList compilationUnits) { foreach (CompilationUnitNode compilationUnit in compilationUnits) { foreach (AttributeBlockNode attribBlock in compilationUnit.Attributes) { string scriptPrefix = GetAttributeValue(attribBlock.Attributes, "ScriptQualifier"); if (scriptPrefix != null) { return(scriptPrefix); } } } return(null); }
public ParameterNode( Token token, ParseNodeList attributes, ParameterFlags flags, ParseNode type, AtomicNameNode name, bool isExtensionMethodTarget = false) : base(ParseNodeType.FormalParameter, token) { Attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); Flags = flags; IsExtensionMethodTarget = isExtensionMethodTarget; Type = GetParentedNode(type); this.name = (AtomicNameNode)GetParentedNode(name); }
public MethodDeclarationNode(Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode returnType, NameNode interfaceType, AtomicNameNode name, ParseNodeList typeParameters, ParseNodeList formals, ParseNodeList constraints, BlockStatementNode body) : this(ParseNodeType.MethodDeclaration, token, attributes, modifiers, returnType, name, formals, body) { this.interfaceType = (NameNode)GetParentedNode(interfaceType); this.typeParameters = GetParentedNodeList(typeParameters); this.constraints = GetParentedNodeList(constraints); }
protected PropertyDeclarationNode(ParseNodeType nodeType, Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode type, NameNode interfaceType, AccessorNode getOrRemove, AccessorNode setOrAdd) : base(nodeType, token) { Attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); Modifiers = modifiers; Type = GetParentedNode(type); this.interfaceType = (NameNode)GetParentedNode(interfaceType); GetAccessor = (AccessorNode)GetParentedNode(getOrRemove); SetAccessor = (AccessorNode)GetParentedNode(setOrAdd); }
protected MethodDeclarationNode(ParseNodeType nodeType, Token token, ParseNodeList attributes, Modifiers modifiers, ParseNode returnType, AtomicNameNode name, ParseNodeList formals, BlockStatementNode body) : base(nodeType, token) { Attributes = GetParentedNodeList(AttributeNode.GetAttributeList(attributes)); Modifiers = modifiers; Type = GetParentedNode(returnType); this.name = (AtomicNameNode)GetParentedNode(name); Parameters = GetParentedNodeList(formals); Implementation = (BlockStatementNode)GetParentedNode(body); }
bool IParseNodeValidator.Validate(ParseNode node, CompilerOptions options, IErrorHandler errorHandler) { NamespaceNode namespaceNode = (NamespaceNode)node; bool valid = true; foreach (ParseNode childNode in namespaceNode.Members) { if (childNode is NamespaceNode) { errorHandler.ReportError("Nested namespaces are not supported.", childNode.Token.Location); valid = false; } } if (namespaceNode.Name.Equals("System") || namespaceNode.Name.StartsWith("System.")) { // Usage of the System namespace is limited to imported types. foreach (ParseNode childNode in namespaceNode.Members) { bool allowed = false; if (childNode is UserTypeNode) { ParseNodeList attributes = ((UserTypeNode)childNode).Attributes; if (AttributeNode.FindAttribute(attributes, "ScriptImport") != null || (AttributeNode.FindAttribute(attributes, "ScriptAllowSystemNamespace") != null)) { allowed = true; } } if (allowed == false) { errorHandler.ReportError("Only types marked as Imported are allowed within the System namespace.", namespaceNode.Token.Location); valid = false; break; } } } return(valid); }
internal void IncludeCompilationUnitUsingClauses() { CompilationUnitNode compilationUnit = (CompilationUnitNode)Parent; if (compilationUnit.UsingClauses.Count != 0) { ParseNodeList mergedUsings = new ParseNodeList(); mergedUsings.Append(compilationUnit.UsingClauses); if (UsingClauses.Count != 0) { mergedUsings.Append(UsingClauses); } UsingClauses = GetParentedNodeList(mergedUsings); } }