Commit d2c02774 authored by Leigh Stoller's avatar Leigh Stoller

Add some simple support for capturing external files that included

into the main NS files via the "source" command.
parent d5c04fa1
......@@ -266,6 +266,9 @@ namespace eval GLOBALS {
# Security level. Defaults to green
variable security_level 0
# List of source files.
variable sourcefile_list {}
#
# Named argument helper function.
#
......@@ -430,6 +433,32 @@ proc set {args} {
return [uplevel real_set \{$var\} \{$val\}]
}
##################################################
# Redifing source
#
# Trap the "source" command so that we can tell the boss-side caller about
# any ns files it has to capture and archive.
#
##################################################
rename source real_source
proc source {args} {
var_import GLOBALS::sourcefile_list
#
# Record the name for later.
#
# XXX Do not record the tb_compat file ...
#
if {[lindex $args 0] != "tb_compat.tcl"} {
lappend sourcefile_list [lindex $args 0]
}
#
# The run real command returning value.
#
return [uplevel real_source \{[lindex $args 0]\}]
}
###
# new <class> ...
# NS defines the new command to create class instances. If the call is
......@@ -543,7 +572,7 @@ proc parse_delay {dspec} {
if { ${GLOBALS::errors} != 1 } {
file copy -force ${GLOBALS::tbcompat} .
source ${GLOBALS::nsfile}
real_source ${GLOBALS::nsfile}
if {${GLOBALS::ran} == 0} {
perror "No 'Simulator run' statement found."
......
......@@ -368,6 +368,7 @@ Simulator instproc run {} {
var_import ::GLOBALS::elabinelab_eid
var_import ::GLOBALS::elabinelab_cvstag
var_import ::GLOBALS::security_level
var_import ::GLOBALS::sourcefile_list
if {$ran == 1} {
perror "The Simulator 'run' statement can only be run once."
......@@ -380,10 +381,10 @@ Simulator instproc run {} {
} else {
set nsfilename "elabinelab-${elabinelab_topo}.ns"
}
uplevel 1 source "@prefix@/lib/ns2ir/${nsfilename}"
uplevel 1 real_source "@prefix@/lib/ns2ir/${nsfilename}"
}
if {$security_level} {
uplevel 1 source "@prefix@/lib/ns2ir/fw.ns"
uplevel 1 real_source "@prefix@/lib/ns2ir/fw.ns"
}
# Fill out IPs
......@@ -617,6 +618,10 @@ Simulator instproc run {} {
$self spitxml_data "eventlist" [list "time" "vnode" "vname" "objecttype" "eventtype" "arguments" "atstring" ] [list [lindex $event 0] [lindex $event 1] [lindex $event 2] $objtypes([lindex $event 3]) $eventtypes([lindex $event 4]) [lindex $event 5] [lindex $event 6] ]
}
foreach sourcefile $sourcefile_list {
$self spitxml_data "external_sourcefiles" [list "pathname" ] [list $sourcefile ]
}
$self spitxml_finish
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment