Package macromedia.asc.parser

Examples of macromedia.asc.parser.ProgramNode


        Context context = new Context(contextStatics);
        context.setHandler(new CompilerHandler());
        AbcParser abcParser = new AbcParser(context, tag.abc);
        context.setEmitter(new ActionBlockEmitter(context, tag.name, new StringPrintWriter(),
                              new StringPrintWriter(), false, false, false, false));
        ProgramNode programNode = abcParser.parseAbc();
       
        if (programNode == null)
        {
          out.println("<!-- Error: could not parse abc -->");
        }
        else if (decompile)
        {
          //                PrettyPrinter prettyPrinter = new PrettyPrinter(out);
          //                programNode.evaluate(context, prettyPrinter);
        }
        else
        {
          SyntaxTreeDumper syntaxTreeDumper = new SyntaxTreeDumper(out, indent);
          programNode.evaluate(context, syntaxTreeDumper);
        }
       
        close(tag);
      }
      else
View Full Code Here


        // name was one of the problems, then the generated file name is unreliable
        // (since it is based on the package name) and could overwrite an existing,
        // valid, signature file
        if ((sigString != null) && (signatureDirectory != null))
        {
            final ProgramNode           pNode    = (ProgramNode)unit.getSyntaxTree();
            final PackageDefinitionNode pdn      = pNode.pkgdefs.first();
            final String                pkgName  = NodeMagic.getPackageName(pdn).replace('.', '_');
            // final VirtualFile           vFile    = unit.getSource().getBackingFile();
           
            // this is only kinda sketchy, but it works... all I need is the file name, not the path
View Full Code Here

        Context context = new Context(contextStatics);
        context.setHandler(new CompilerHandler());
        AbcParser abcParser = new AbcParser(context, tag.abc);
        context.setEmitter(new ActionBlockEmitter(context, tag.name, new StringPrintWriter(),
                              new StringPrintWriter(), false, false, false, false));
        ProgramNode programNode = abcParser.parseAbc();
       
        if (programNode == null)
        {
          out.println("<!-- Error: could not parse abc -->");
        }
        else if (decompile)
        {
          //                PrettyPrinter prettyPrinter = new PrettyPrinter(out);
          //                programNode.evaluate(context, prettyPrinter);
        }
        else
        {
          SyntaxTreeDumper syntaxTreeDumper = new SyntaxTreeDumper(out, indent);
          programNode.evaluate(context, syntaxTreeDumper);
        }
       
        close(tag);
      }
      else
View Full Code Here

    {
      return unit;
    }

    final String path = source.getName();
    ProgramNode node = null;

    CompilerContext context = new CompilerContext();

    Context cx = new Context(symbolTable.perCompileData);

    cx.setScriptName(source.getName());
    cx.setPath(source.getParent());

    cx.setEmitter(symbolTable.emitter);
    cx.setHandler(new As3Compiler.CompilerHandler()
    {
      public void error2(String filename, int ln, int col, Object msg, String source)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        ThreadLocalToolkit.log((flex2.compiler.util.CompilerMessage) msg, filename);
      }

      public void warning2(String filename, int ln, int col, Object msg, String source)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        ThreadLocalToolkit.log((CompilerMessage) msg, filename);
      }

      public void error(String filename, int ln, int col, String msg, String source, int errorCode)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        if (errorCode != -1)
        {
          ThreadLocalToolkit.logError(filename, msg, errorCode);
        }
        else
        {
          ThreadLocalToolkit.logError(filename, msg);
        }
      }

      public void warning(String filename, int ln, int col, String msg, String source, int errorCode)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        if (errorCode != -1)
        {
          ThreadLocalToolkit.logWarning(filename, msg, errorCode);
        }
        else
        {
          ThreadLocalToolkit.logWarning(filename, msg);
        }
      }

      public void error(String filename, int ln, int col, String msg, String source)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        ThreadLocalToolkit.logError(filename, msg);
      }

      public void warning(String filename, int ln, int col, String msg, String source)
      {
        filename = (filename == null || filename.length() == 0) ? path : filename;
        ThreadLocalToolkit.logWarning(filename, msg);
      }

      public FileInclude findFileInclude(String parentPath, String filespec)
      {
        return null;
      }
    });
    symbolTable.perCompileData.handler = cx.getHandler();

    context.setAscContext(cx);

    byte[] abc = null;
    try
    {
      abc = source.toByteArray();

      if (abc == null)
      {
        abc = FileUtils.toByteArray(source.getInputStream());
      }

      if (abc == null || abc.length == 0)
      {
        ThreadLocalToolkit.log(new NoBytecodeIsAvailable(), source);
      }
      else
      {
          AbcParser parser = new AbcParser(cx, abc);
          node = parser.parseAbc();

                if (node == null && ThreadLocalToolkit.errorCount() == 0)
                {
                    ThreadLocalToolkit.log(new BytecodeDecodingFailed(), source);
                }

                As3Compiler.cleanNodeFactory(cx.getNodeFactory());
      }
    }
    catch (IOException ex)
    {
      ThreadLocalToolkit.logError(source.getNameForReporting(), ex.getLocalizedMessage());
    }

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

        if (unit == null)
        {
            unit = source.newCompilationUnit(node, context);
        }
        else
        {
            unit.setSyntaxTree(node);
            unit.getContext().setAttributes(context);
        }

    unit.bytes.set(abc, abc.length);

    SyntaxTreeEvaluator treeEvaluator = new SyntaxTreeEvaluator(unit);
    treeEvaluator.setLocalizationManager(ThreadLocalToolkit.getLocalizationManager());
    node.evaluate(cx, treeEvaluator);

    for (int i = 0, length = compilerExtensions.size(); i < length; i++)
    {
      compilerExtensions.get(i).parse1(unit, null);
View Full Code Here

        if (unit.hasTypeInfo)
    {
      return;
    }

    ProgramNode node = (ProgramNode) unit.getSyntaxTree();
    if (node.state != ProgramNode.Inheritance)
    {
      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

        if (unit.hasTypeInfo)
    {
      return;
    }

    ProgramNode node = (ProgramNode) unit.getSyntaxTree();
    if (node.state != ProgramNode.Else)
    {
      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

        if (unit.hasTypeInfo)
    {
      return;
    }

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

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

      As3Compiler.evaluateLoaderClassBase(unit, typeTable);
      return;
    }

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

    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;
View Full Code Here

  }

    private void inheritSlots(CompilationUnit unit, Set<Name> types, SymbolTable symbolTable)
  {
    CompilerContext context = unit.getContext();
    ProgramNode node = (ProgramNode) unit.getSyntaxTree();
   
    Context cx = context.getAscContext();
       
    @SuppressWarnings("unchecked")
    Set<String> processed = (Set<String>) context.getAttribute("processed");
View Full Code Here

      }
    };
    cx.setHandler(newHandler);
    cx.scriptAssistParsing = true;
    Parser parser = new Parser(cx, s, "Expression"); //$NON-NLS-1$
    ProgramNode programNode = parser.parseProgram();

    if (errors.size() > 0) {
      ErrorInfo firstError = errors.get(0);
      throw new ParseException(firstError.msg, firstError.col);
    }
View Full Code Here

TOP

Related Classes of macromedia.asc.parser.ProgramNode

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.