| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | var NullDependency = require("./NullDependency"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function ConstDependency(expression, range) { | 
					
						
							|  |  |  | 	NullDependency.call(this); | 
					
						
							|  |  |  | 	this.expression = expression; | 
					
						
							|  |  |  | 	this.range = range; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = ConstDependency; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ConstDependency.prototype = Object.create(NullDependency.prototype); | 
					
						
							| 
									
										
										
										
											2015-05-10 23:12:10 +08:00
										 |  |  | ConstDependency.prototype.constructor = ConstDependency; | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | ConstDependency.Template = function ConstDependencyTemplate() {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-24 05:55:50 +08:00
										 |  |  | ConstDependency.Template.prototype.apply = function(dep, source) { | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(typeof dep.range === "number") | 
					
						
							| 
									
										
										
										
											2014-03-03 21:56:17 +08:00
										 |  |  | 		source.insert(dep.range, dep.expression); | 
					
						
							|  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2015-04-24 05:55:50 +08:00
										 |  |  | 		source.replace(dep.range[0], dep.range[1] - 1, dep.expression); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2015-09-03 20:17:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | ConstDependency.prototype.updateHash = function(hash) { | 
					
						
							|  |  |  | 	hash.update(this.range + ""); | 
					
						
							|  |  |  | 	hash.update(this.expression + ""); | 
					
						
							|  |  |  | }; |