Package macromedia.asc.util

Examples of macromedia.asc.util.Context


    }

    public static Context generateContext(ContextStatics contextStatics, Source source, BytecodeEmitter emitter,
                                          ObjectList<ConfigVar> defines)
    {
        Context result = new Context(contextStatics);
        result.setOrigin(source.getBackingFile().getName());
        result.setScriptName(source.getBackingFile().getName());
        result.setPath(source.getBackingFile().getParent());
        result.setEmitter(emitter);
        result.setHandler(new As3Compiler.CompilerHandler(source));
        result.input = new CodeFragmentsInputBuffer(source.getBackingFile().getName());

        if (defines != null)
        {
            result.config_vars.addAll(defines);
View Full Code Here


       
        assert swfVersion != null : "header should have been parsed already, but wasn't";
        contextStatics.setAbcVersion(ContextStatics.getTargetAVM(swfVersion));
        contextStatics.use_namespaces.addAll(ContextStatics.getRequiredUseNamespaces(swfVersion));
       
        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)
        {
View Full Code Here

    catch (UnsupportedEncodingException ex)
    {
      // not possible...
    }*/

    Context context = new Context((ContextStatics) perCompileData);
    context.setPath(file.getParent());
    context.setScriptName(file.getName());
    context.setHandler(new flex2.compiler.as3.As3Compiler.CompilerHandler()
    {
      public void error2(String filename, int ln, int col, Object msg, String source)
      {
        ThreadLocalToolkit.log(new InvalidMetadataFormatError(), filename, beginLine);
      }

      public void warning2(String filename, int ln, int col, Object msg, String source)
      {
        ThreadLocalToolkit.log(new InvalidMetadataFormatWarning(), filename, beginLine);
      }

      public void error(String filename, int ln, int col, String msg, String source, int errorCode)
      {
        ThreadLocalToolkit.log(new InvalidMetadataFormatError(), filename, beginLine);       
      }
     
      public void error(String filename, int ln, int col, String msg, String source)
      {
        ThreadLocalToolkit.log(new InvalidMetadataFormatError(), filename, beginLine);
      }

      public void warning(String filename, int ln, int col, String msg, String source, int errorCode)
      { 
        ThreadLocalToolkit.log(new InvalidMetadataFormatWarning(), filename, beginLine);
      }

      public void warning(String filename, int ln, int col, String msg, String source)
      {
        ThreadLocalToolkit.log(new InvalidMetadataFormatWarning(), filename, beginLine);
      }

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

    Parser parser = new Parser(context, stringBuffer.toString(), file.getName());
    MetaDataNode metaDataNode = parser.parseMetaData();
    macromedia.asc.parser.MetaDataEvaluator metaDataEvaluator = new macromedia.asc.parser.MetaDataEvaluator();
    metaDataNode.evaluate(context, metaDataEvaluator);

    return context.errorCount() > 0 ? null : new MetaData(metaDataNode);
  }
View Full Code Here

    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());
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

    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

    }

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

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

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

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

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

    }

    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

      {
        return;
      }
    }

    Context cx = unit.getContext().removeAscContext();
    As3Compiler.cleanSlots(unit.typeInfo, cx, unit.topLevelDefinitions);
    cx.setHandler(null);

        if (benchmarkHelper != null)
            benchmarkHelper.endPhase(CompilerBenchmarkHelper.GENERATE);
  }
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");

    for (Name name : types)
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.