Class: Cfruby::Cfp_Execute
- Inherits:
-
Object
- Object
- Cfruby::Cfp_Execute
- Defined in:
- lib/libcfenjin/cfp_execute.rb
Instance Method Summary collapse
-
#do_execute(code) ⇒ Object
Calls a method of a (pre-compiled) class.
-
#initialize(cf) ⇒ Cfp_Execute
constructor
A new instance of Cfp_Execute.
Constructor Details
#initialize(cf) ⇒ Cfp_Execute
Returns a new instance of Cfp_Execute.
21 22 23 24 |
# File 'lib/libcfenjin/cfp_execute.rb', line 21 def initialize cf @cf = cf @executeclasslist = Hash.new end |
Instance Method Details
#do_execute(code) ⇒ Object
Calls a method of a (pre-compiled) class. If the class does not exist in the runtime space it gets initialised
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/libcfenjin/cfp_execute.rb', line 28 def do_execute code classname = code.classname method = code.methodname return if method == 'initialize' # @cf.cfp_logger.trace TRACE_ENGINE,"Executing #{classname}.#{method}" # Make sure global and class level variables exist sourcepath = File.dirname(code.fn) homepath = ENV['HOME'] user = ENV['USER'] # @@FIXME begin iname = '@'+instancename(classname) if !@executeclasslist[classname] # ---- Create new class and add into runtime space scode = "#{iname} = Cfp_Compile::#{classname}.new @cf,sourcepath,homepath,user" @cf.cfp_logger.trace TRACE_ENGINE,'Executing: '+scode eval scode @executeclasslist[classname] = Cfp_ExecuteClass.new(classname) end if !@executeclasslist[classname].skip scode = "#{iname}.#{method}" @cf.cfp_logger.trace TRACE_ENGINE,'Executing: '+scode eval scode end rescue CfrubyRuntime::PackageNotInstalledError, CfrubyRuntime::ExitScript @executeclasslist[classname].skip = true rescue msg = 'ERROR cfscript ',code.fn," line #{code.linenum} - #{$!}\n" code.dump @cf.cfp_logger.error LOG_CRIT,msg,'cfruby' raise end end |