Package macromedia.asc.util

Examples of macromedia.asc.util.Context


              }
            }
          }
        }

        context = new Context(context.statics);
        context.setPath("");
        context.setScriptName(generatedName);
        context.setHandler(new flex2.compiler.as3.As3Compiler.CompilerHandler());
        context.statics.handler = context.getHandler();
View Full Code Here


     *
     */
    public void parse1(CompilationUnit unit, TypeTable typeTable)
    {
        Node node = (Node) unit.getSyntaxTree();
        Context cx = unit.getContext().getAscContext();
        GenerativeFirstPassEvaluator firstPassEvaluator = getFirstPassEvaluator(unit, typeTable);

        node.evaluate(cx, firstPassEvaluator);

        if ( firstPassEvaluator.makeSecondPass() )
View Full Code Here

            (GenerativeFirstPassEvaluator) unit.getContext().removeAttribute(getFirstPassEvaluatorKey());

        if (firstPassEvaluator != null && firstPassEvaluator.makeSecondPass())
        {
            Node node = (Node) unit.getSyntaxTree();
            Context cx = unit.getContext().getAscContext();
            TypeAnalyzer typeAnalyzer = typeTable.getSymbolTable().getTypeAnalyzer();

            node.evaluate(cx, typeAnalyzer);

            Iterator iterator = firstPassEvaluator.getClassMap().entrySet().iterator();
View Full Code Here

        }

    String path = source.getName();
    ProgramNode node = null;
        CompilerContext context = null;
        Context cx;

        if ((unit != null) && (unit.getSyntaxTree() != null))
        {
            node = (ProgramNode) unit.getSyntaxTree();
            cx = node.cx;
        }
        else
        {
            context = new CompilerContext();
            cx = new Context(symbolTable.perCompileData);
            cx.setScriptName(source.getName());
            cx.setPath(source.getParent());

            cx.setEmitter(symbolTable.emitter);
            cx.setHandler(new CompilerHandler(source));
            symbolTable.perCompileData.handler = cx.getHandler();

            context.setAscContext(cx);

            // conditional compilation: add config settings from the compiler configuration
            // this must be done BEFORE parsing
            final ObjectList<ConfigVar> arr = as3Configuration.getDefine();
            if (arr != null)
            {
                cx.config_vars.addAll(arr);
            }

            assert cx.getNodeFactory().compound_names.size() == 0 : "cleanNodeFactory() should have been called";

            if (source.isTextBased())
            {
                Parser parser = new Parser(cx, source.getInputText(), path, as3Configuration.doc(), false);
                node = parser.parseProgram();

                source.close();
                cleanNodeFactory(cx.getNodeFactory());
            }
            else
            {
                BufferedInputStream in = null;

                try
                {
                    in = new BufferedInputStream(source.getInputStream());
                    Parser parser = null;
                    if (as3Configuration.doc())
                    {
                        if (as3Configuration.getEncoding() == null)
                        {
                            parser = new Parser(cx, in, path, true, false);
                        }
                        else
                        {
                            parser = new Parser(cx, in, path, as3Configuration.getEncoding(), true, false);
                        }
                    }
                    else
                    {
                        if (as3Configuration.getEncoding() == null)
                        {
                            parser = new Parser(cx, in, path);
                        }
                        else
                        {
                            parser = new Parser(cx, in, path, as3Configuration.getEncoding());
                        }
                    }
                    node = parser.parseProgram();

                    cleanNodeFactory(cx.getNodeFactory());
                }
                catch (IOException ex)
                {
                    ThreadLocalToolkit.logError(source.getNameForReporting(), ex.getLocalizedMessage());
                }
View Full Code Here

    {
      return;
    }

    CompilerContext context = unit.getContext();
    Context cx = context.getAscContext();
    symbolTable.perCompileData.handler = cx.getHandler();

    ObjectValue global = new ObjectValue(cx, new GlobalBuilder(), null);
    cx.pushScope(global); // first scope is always considered the global scope.

    // run FlowAnalyzer
    FlowGraphEmitter flowem = new FlowGraphEmitter(cx, unit.getSource().getName(), false);
    FlowAnalyzer flower = new FlowAnalyzer(flowem);
    context.setAttribute("FlowAnalyzer", flower);

    // 1. ProgramNode.state == Inheritance
    node.evaluate(cx, flower);
    cx.popScope();

    if (ThreadLocalToolkit.errorCount() > 0)
    {
      return;
    }
View Full Code Here

    {
      return;
    }

    CompilerContext context = unit.getContext();
    Context cx = context.getAscContext();
    symbolTable.perCompileData.handler = cx.getHandler();

    FlowAnalyzer flower = (FlowAnalyzer) context.getAttribute("FlowAnalyzer");
    context.setAttribute("processed", new HashSet(15));

    inheritSlots(unit, unit.inheritance, symbolTable);
    inheritSlots(unit, unit.namespaces, symbolTable);

    cx.pushScope(node.frame);
    // 2. ProgramNode.state == Else
    node.evaluate(cx, flower);
    cx.popScope();

    if (ThreadLocalToolkit.errorCount() > 0)
    {
      return;
    }
View Full Code Here

    {
      return;
    }

    CompilerContext context = unit.getContext();
    Context cx = context.getAscContext();
    symbolTable.perCompileData.handler = cx.getHandler();

    inheritSlots(unit, unit.types, symbolTable);
    inheritSlots(unit, unit.namespaces, symbolTable);

    // C: If --coach is turned on, do inheritSlots for unit.expressions here...
        if (as3Configuration.strict() || as3Configuration.warnings())
        {
        inheritSlots(unit, unit.expressions, symbolTable);
        }

    if (as3Configuration.strict())
    {
      verifyImportPackages(unit.importPackageStatements, context);
      verifyImportDefinitions(unit.importDefinitionStatements, context);
    }

    if (true /*configuration.metadataExport()*/ && ! unit.getSource().isInternal())
        {
            cx.pushScope(node.frame);
          // C: for SWC generation, use debug(). this makes MetaDataEvaluator generate go-to-definition metadata.
          //    it's okay because compc doesn't use PostLink
          //    for debug-mode movies, MetaDataEvaluator will generate go-to-definition metadata.
          //    But PostLink will take them out.
            macromedia.asc.parser.MetaDataEvaluator printer =
                new macromedia.asc.parser.MetaDataEvaluator(as3Configuration.debug(), !as3Configuration.optimize());
            node.evaluate(cx,printer);

          if (as3Configuration.doc() && unit.getSource().isDebuggable())
          {
            StringBuilder out = new StringBuilder();
            out.append("<asdoc>").append("\n");

            ObjectList comments = printer.doccomments;
            int numComments = comments.size();
            for(int x = 0; x < numComments; x++)
            {
              ((DocCommentNode) comments.get(x)).emit(cx,out);
            }
            out.append("\n").append("</asdoc>").append("\n");
          }

          cx.popScope();
        }

        if (ThreadLocalToolkit.errorCount() > 0)
        {
            return;
        }

        // run ConstantEvaluator
    cx.pushScope(node.frame);
    ConstantEvaluator analyzer = new ConstantEvaluator(cx);
    context.setAttribute("ConstantEvaluator", analyzer);
    analyzer.PreprocessDefinitionTypeInfo(cx, node);
    cx.popScope();

    if (ThreadLocalToolkit.errorCount() > 0)
    {
        return;
    }
View Full Code Here

        {
            return;
        }

        CompilerContext context = unit.getContext();
        Context cx = context.getAscContext();
        symbolTable.perCompileData.handler = cx.getHandler();

        // run ConstantEvaluator
        cx.pushScope(node.frame);
        ConstantEvaluator analyzer = (ConstantEvaluator) context.removeAttribute("ConstantEvaluator");
    node.evaluate(cx, analyzer);
    cx.popScope();

    if (ThreadLocalToolkit.errorCount() > 0)
    {
      return;
    }

    // run -strict and -coach
    if (as3Configuration.warnings())
    {
      cx.pushScope(node.frame);

      LintEvaluator lint = new LintEvaluator(cx, unit.getSource().getName(), warnMap);
      node.evaluate(cx, lint);
      cx.popScope();
            lint.simpleLogWarnings(cx, coachWarningsAsErrors);
            // if we want to go back to the verbose style of warnings, uncomment the line below and
            // comment out the line above
            //lint.logWarnings(context.cx);
View Full Code Here

        }

    TypeTable typeTable = (TypeTable) symbolTable.getContext().getAttribute(AttrTypeTable);

    CompilerContext context = unit.getContext();
    Context cx = context.getAscContext();
    symbolTable.perCompileData.handler = cx.getHandler();

    ProgramNode node = (ProgramNode) unit.getSyntaxTree();

    LineNumberMap map = (LineNumberMap) context.getAttribute("LineNumberMap");

    Emitter emitter = new BytecodeEmitter(cx, unit.getSource(),
                                              as3Configuration.debug() || as3Configuration.verboseStacktraces(),
                                              !as3Configuration.optimize(),
                                              as3Configuration.keepEmbedMetadata(),
                                          as3Configuration.adjustOpDebugLine() ? map : null);

    cx.pushScope(node.frame);
    CodeGenerator generator = new CodeGenerator(emitter);
    if (RuntimeConstants.SWF)
    {
      generator.push_args_right_to_left(true);
    }
    node.evaluate(cx, generator);
    cx.popScope();

    if (ThreadLocalToolkit.errorCount() > 0)
    {
      return;
    }

    emitter.emit(unit.bytes);

    for (int i = 0, length = compilerExtensions.size(); i < length; i++)
    {
      compilerExtensions.get(i).generate(unit, typeTable);

      if (ThreadLocalToolkit.errorCount() > 0)
      {
        return;
      }
    }

    cleanSlots(unit.typeInfo, cx, unit.topLevelDefinitions);
    unit.getContext().removeAscContext();
    cx.setHandler(null);
       
        if (benchmarkHelper != null)
        {
            benchmarkHelper.endPhase(CompilerBenchmarkHelper.GENERATE);
        }
View Full Code Here

    unresolved.clear();
  }

  private void verifyImportPackages(Set<String> imports, CompilerContext context)
  {
    Context cx = context.getAscContext();

    for (String importName : imports)
    {
      ObjectValue ns = cx.getNamespace(importName);
      if (ns != null)
      {
        ns.setPackage(true);
      }
    }
View Full Code Here

TOP

Related Classes of macromedia.asc.util.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.