| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // parameters which then can be executed. If the source code contains other | 41 // parameters which then can be executed. If the source code contains other |
| 42 // functions, they will be compiled and allocated as part of the compilation | 42 // functions, they will be compiled and allocated as part of the compilation |
| 43 // of the source code. | 43 // of the source code. |
| 44 | 44 |
| 45 // Please note this interface returns function boilerplates. | 45 // Please note this interface returns function boilerplates. |
| 46 // This means you need to call Factory::NewFunctionFromBoilerplate | 46 // This means you need to call Factory::NewFunctionFromBoilerplate |
| 47 // before you have a real function with context. | 47 // before you have a real function with context. |
| 48 | 48 |
| 49 class Compiler : public AllStatic { | 49 class Compiler : public AllStatic { |
| 50 public: | 50 public: |
| 51 enum ValidationState { VALIDATE_JSON, DONT_VALIDATE_JSON }; |
| 52 |
| 51 // All routines return a JSFunction. | 53 // All routines return a JSFunction. |
| 52 // If an error occurs an exception is raised and | 54 // If an error occurs an exception is raised and |
| 53 // the return handle contains NULL. | 55 // the return handle contains NULL. |
| 54 | 56 |
| 55 // Compile a String source within a context. | 57 // Compile a String source within a context. |
| 56 static Handle<JSFunction> Compile(Handle<String> source, | 58 static Handle<JSFunction> Compile(Handle<String> source, |
| 57 Handle<Object> script_name, | 59 Handle<Object> script_name, |
| 58 int line_offset, int column_offset, | 60 int line_offset, int column_offset, |
| 59 v8::Extension* extension, | 61 v8::Extension* extension, |
| 60 ScriptDataImpl* script_Data); | 62 ScriptDataImpl* script_Data); |
| 61 | 63 |
| 62 // Compile a String source within a context for Eval. | 64 // Compile a String source within a context for Eval. |
| 63 static Handle<JSFunction> CompileEval(Handle<String> source, | 65 static Handle<JSFunction> CompileEval(Handle<String> source, |
| 64 Handle<Context> context, | 66 Handle<Context> context, |
| 65 bool is_global, | 67 bool is_global, |
| 66 bool is_json); | 68 ValidationState validation); |
| 67 | 69 |
| 68 // Compile from function info (used for lazy compilation). Returns | 70 // Compile from function info (used for lazy compilation). Returns |
| 69 // true on success and false if the compilation resulted in a stack | 71 // true on success and false if the compilation resulted in a stack |
| 70 // overflow. | 72 // overflow. |
| 71 static bool CompileLazy(Handle<SharedFunctionInfo> shared, int loop_nesting); | 73 static bool CompileLazy(Handle<SharedFunctionInfo> shared, int loop_nesting); |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 | 76 |
| 75 // During compilation we need a global list of handles to constants | 77 // During compilation we need a global list of handles to constants |
| 76 // for frame elements. When the zone gets deleted, we make sure to | 78 // for frame elements. When the zone gets deleted, we make sure to |
| 77 // clear this list of handles as well. | 79 // clear this list of handles as well. |
| 78 class CompilationZoneScope : public ZoneScope { | 80 class CompilationZoneScope : public ZoneScope { |
| 79 public: | 81 public: |
| 80 explicit CompilationZoneScope(ZoneScopeMode mode) : ZoneScope(mode) { } | 82 explicit CompilationZoneScope(ZoneScopeMode mode) : ZoneScope(mode) { } |
| 81 virtual ~CompilationZoneScope() { | 83 virtual ~CompilationZoneScope() { |
| 82 if (ShouldDeleteOnExit()) { | 84 if (ShouldDeleteOnExit()) { |
| 83 FrameElement::ClearConstantList(); | 85 FrameElement::ClearConstantList(); |
| 84 Result::ClearConstantList(); | 86 Result::ClearConstantList(); |
| 85 } | 87 } |
| 86 } | 88 } |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 | 91 |
| 90 } } // namespace v8::internal | 92 } } // namespace v8::internal |
| 91 | 93 |
| 92 #endif // V8_COMPILER_H_ | 94 #endif // V8_COMPILER_H_ |
| OLD | NEW |