public boolean isCustomNamespace(FunctionNode node) { INamespaceDecorationNode ns = ((FunctionNode)node).getActualNamespaceNode(); if (ns != null) { String nsName = node.getNamespace(); if (!(nsName == IASKeywordConstants.PRIVATE || nsName == IASKeywordConstants.PROTECTED || nsName == IASKeywordConstants.INTERNAL || nsName == INamespaceConstants.AS3URI || nsName == IASKeywordConstants.PUBLIC)) { return true; } } return false; }
@Override public void emitLocalNamedFunction(IFunctionNode node) { FunctionNode fnode = (FunctionNode) node; write(ASEmitterTokens.FUNCTION); write(ASEmitterTokens.SPACE); write(fnode.getName()); emitParameters(fnode.getParametersContainerNode()); emitType(fnode.getTypeNode()); emitFunctionScope(fnode.getScopedNode()); }
@Override public synchronized void populateFunctionNodes() { for (final FunctionNode fn : deferredFunctionNodes) { fn.parseFunctionBody(problems); } }
@Override protected void setChildren(boolean fillInOffsets) { addDecorationChildren(fillInOffsets); addChildInOrder(contentsPart.getFunctionKeywordNode(), fillInOffsets); addChildInOrder(nameNode, fillInOffsets); addChildInOrder(contentsPart.getParametersNode(), fillInOffsets); addChildInOrder(typeNode, fillInOffsets); addChildInOrder(contentsPart.getContents(), fillInOffsets); }
@Override public String getQualifiedName() { String qualifiedName = null; if (isPackageLevelFunction()) { IImportTarget importTarget = ASImportTarget.buildImportFromPackageName(getWorkspace(), getPackageName()); qualifiedName = importTarget.getQualifiedName(getName()); } if (qualifiedName == null) qualifiedName = getName(); return qualifiedName; }
assert ( func.getNameExpressionNode() != null ): "Function has null name expression"; assert ( func.getParametersContainerNode() != null ): "Function has null parameters"; result = 2; if ( func.getReturnTypeNode() != null ) result++; if ( func.getScopedNode() != null ) result++;
void declareFunction(FunctionNode func) func.parseFunctionBody(classScope.getProblems()); final FunctionDefinition funcDef = func.getDefinition(); final boolean is_constructor = func.isConstructor(); if ( func.hasModifier(ASModifier.FINAL)) tv.visitAttribute(Trait.TRAIT_FINAL, Boolean.TRUE); if (!wasOverride && (func.hasModifier(ASModifier.OVERRIDE) || funcDef.isOverride())) tv.visitAttribute(Trait.TRAIT_OVERRIDE, Boolean.TRUE); tv.visitEnd(); else funcTypeName = NAME_OBJECT; DefinitionBase bindableGetter = func.buildBindableGetter(funcName.getBaseName()); ASScope funcScope = (ASScope)funcDef.getContainingScope(); bindableGetter.setContainingScope(funcScope); funcTypeName = NAME_OBJECT; ASScope funcScope = (ASScope)funcDef.getContainingScope(); DefinitionBase bindableSetter = func.buildBindableSetter(funcName.getBaseName(), funcScope, funcDef.getTypeReference());
assert contents != null : "Function body node can't be null: function " + getName(); final String sourcePath = getSourcePath(); assert sourcePath != null && !sourcePath.isEmpty() : "Souce path not set."; final FileNode fileNode = (FileNode)getAncestorOfType(FileNode.class); assert fileNode != null : "FileNode not found: function " + getName(); final IWorkspace workspace = fileNode.getWorkspace(); assert !anyNonParametersInScope(contents); fileNode, configProcessor); filterObsoleteProblems(fileNode, functionLocalProblems); problems.addAll(functionLocalProblems); tryAddDefaultArgument(); problems.add(new InternalCompilerProblem2(this.getSourcePath(), e, "function body parser"));
@Override public void emitLocalNamedFunction(IFunctionNode node) { startMapping(node); FunctionNode fnode = (FunctionNode)node; write(ASEmitterTokens.FUNCTION); write(ASEmitterTokens.SPACE); write(fnode.getName()); endMapping(node); emitParameters(fnode.getParametersContainerNode()); emitFunctionScope(fnode.getScopedNode()); }
FunctionDefinition buildDefinition() { String definitionName = getName(); // System.out.println("buildDefinition: " + definitionName); FunctionDefinition definition = createFunctionDefinition(definitionName); definition.setNode(this); fillInNamespaceAndModifiers(definition); fillInMetadata(definition); // Set the return type. If a type annotation doesn't appear in the source, // the return type in the definition will be "". IReference returnType = typeNode != null ? typeNode.computeTypeReference() : null; definition.setReturnTypeReference(returnType); definition.setTypeReference(ReferenceFactory.builtinReference(IASLanguageConstants.BuiltinType.FUNCTION)); setConstructorIfNeeded(definition); return definition; }
@Override public boolean isConstructor() { String name = getName(); String returnType = getReturnType(); // Allow constructors that have a (bogus) return type if (!returnType.equals("") && !returnType.equals(name) && !isAnyType() && !isVoidType()) { return false; } if (getParent() != null && getParent().getParent() != null && (getParent().getParent() instanceof ClassNode || getParent().getParent() instanceof InterfaceNode)) { if (name.equals(((IDefinitionNode) getParent().getParent()).getShortName())) return true; } return false; }
constructorNameNode.setReferenceValue(getDefinition()); constructorNameNode.span(getNameAbsoluteStart(), getNameAbsoluteEnd(), -1, -1); defaultConstructorNode = new FunctionNode(null, constructorNameNode); NamespaceIdentifierNode pub = new NamespaceIdentifierNode(INamespaceConstants.public_); pub.span(-1, -1, -1, -1); defaultConstructorNode.setNamespace(pub); defaultConstructorNode.normalize(true); defaultConstructorNode.setParent(contentsNode); ctorDef = defaultConstructorNode.buildDefinition(); ctorDef.setImplicit(); ctorDef = constructorNode.getDefinition();
f = new FunctionNode((ASToken)functionT, name); n = new FunctionObjectNode(f); f.startBefore(functionT); n.startBefore(functionT); b = f.getScopedNode(); disableSemicolonInsertion(); match(TOKEN_PAREN_OPEN); p = f.getParametersContainerNode(); p.startBefore(lpT);
FunctionNode constructorNode = new FunctionNode(null, constructorNameNode); constructorNode.setNamespace(new NamespaceIdentifierNode(INamespaceConstants.public_)); ScopedBlockNode constructorContents = constructorNode.getScopedNode();
@Override public void emitFunctionObject(IFunctionObjectNode node) { FunctionNode fnode = node.getFunctionNode(); write(ASEmitterTokens.FUNCTION); emitParameters(fnode.getParametersContainerNode()); emitType(fnode.getTypeNode()); emitFunctionScope(fnode.getScopedNode()); }
if (!isBodyDeferred || containsLocalFunctions()) return; return; final ScopedBlockNode contents = getScopedNode(); if (contents.getChildCount() > 0) final FileNode fileNode = (FileNode)getAncestorOfType(FileNode.class); ASFileScope fileScope = fileNode.getFileScope(); fileScope.removeParsedFunctionBodies(this); assert (contents.getScope() == null) || (!anyNonParametersInScope(contents));
functionNode.parseFunctionBody(new ArrayList<ICompilerProblem>()); final ScopedBlockNode functionBody = functionNode.getScopedNode(); if (functionBodyHasNonInlineableNodes(functionBody, reportInlineProblems, function.getBaseName(), new AtomicInteger())) functionNode.discardFunctionBody(); return false;
FunctionDefinition func = node.getDefinition(); if( node.getActualNamespaceNode() != null && node.getActualNamespaceNode().getName() != IASKeywordConstants.PUBLIC) problems.add(new ConstructorMustBePublicProblem(node.getActualNamespaceNode())); IExpressionNode returnTypeExpression = node.getReturnTypeNode(); if (returnTypeExpression != null) problems.add(new ConstructorIsGetterSetterProblem(node.getNameExpressionNode())); problems.add(new OverrideNotFoundProblem(node.getNameExpressionNode())); problems.add(new IncompatibleOverrideProblem(node.getNameExpressionNode())); problems.add(new OverrideFinalProblem(node.getNameExpressionNode())); problems.add(new FunctionNotMarkedOverrideProblem(node.getNameExpressionNode()));
@Override public boolean hasBody() { ScopedBlockNode sbn = getScopedNode(); return sbn.getChildCount() > 0 || sbn.getContainerType() != IContainerNode.ContainerType.SYNTHESIZED; }
fn.parseFunctionBody(new ArrayList<ICompilerProblem>()); IFunctionDefinition.FunctionClassification classification = fn.getFunctionClassification(); if(classification == IFunctionDefinition.FunctionClassification.FILE_MEMBER || classification == IFunctionDefinition.FunctionClassification.PACKAGE_MEMBER) write(fjs.formatQualifiedName(fn.getQualifiedName())); if (!isConstructor) if (!fn.hasModifier(ASModifier.STATIC))