Browse files

A couple more CallFrame/Sub introspectors and two new test files

  • Loading branch information...
1 parent 1767fe8 commit f5a1f340a4a1e823dd98e8cfdcd7358f86b39b0a @sorear committed May 31, 2011
Showing with 20 additions and 0 deletions.
  1. +4 −0 lib/Builtins.cs
  2. +2 −0 lib/CLRBackend.cs
  3. +12 −0 lib/CORE.setting
  4. +2 −0 t/spectest.data
View
4 lib/Builtins.cs
@@ -1061,6 +1061,10 @@ class SubstrLValue: Variable {
return Kernel.NewROScalar(l);
}
+ public static string frame_subname(Frame fr) {
+ return fr.info.name.Substring(fr.info.name.IndexOf(" ")+1);
+ }
+
public static int bif_arity(P6any fcni) {
if (!fcni.Isa(Kernel.SubMO))
return 1; // can't introspect fake subs (?)
View
2 lib/CLRBackend.cs
@@ -3880,6 +3880,8 @@ class NamProcessor {
thandlers["to_json"] = Methody(null, typeof(JsonWriter).GetMethod("ToJson"));
thandlers["from_json"] = Methody(null, typeof(JsyncReader).GetMethod("FromJson"));
thandlers["frame_caller"] = FieldGet(Tokens.Frame, "caller");
+ thandlers["frame_args"] = Methody(null, Tokens.Frame.GetMethod("GetArgs"));
+ thandlers["frame_dyn_caller"] = Methody(null, Tokens.Frame.GetMethod("DynamicCaller"));
thandlers["frame_file"] = Methody(null, Tokens.Frame.GetMethod("ExecutingFile"));
thandlers["frame_line"] = Methody(null, Tokens.Frame.GetMethod("ExecutingLine"));
thandlers["frame_hint"] = Methody(null, Tokens.Frame.GetMethod("LexicalFind"));
View
12 lib/CORE.setting
@@ -288,6 +288,8 @@ my class Sub {
# Should be for Block, not Sub
method ACCEPTS(Mu $t) { defined(self) ?? (self)($t) !! $t.^does(self) }
+ method arity() { Q:CgOp { (box Int (_cgop bif_arity (@ {self}))) } }
+ method outer() { Q:CgOp { (ns (getslot outer frame (@ {self}))) } }
method perl() { defined(self) ?? '{ ... }' !! self.typename }
}
@@ -453,11 +455,21 @@ my class CallFrame {
(ns (l c))
{Any}))
} }
+ method dynamic-caller() { Q:CgOp {
+ (letn c (_cgop frame_dyn_caller (cast frame (@ {self})))
+ (ternary
+ (!= (l c) (null frame))
+ (ns (l c))
+ {Any}))
+ } }
method file() { Q:CgOp { (box Str (frame_file
(cast frame (@ {self})))) } }
method line() { Q:CgOp { (box Num (cast num (frame_line
(cast frame (@ {self}))))) } }
+ method subname() { Q:CgOp { (box Str (_cgop frame_subname
+ (cast frame (@ {self})))) } }
+ method args() { Q:CgOp { (_cgop frame_args (cast frame (@ {self}))) } }
method hints($var) { Q:CgOp { (frame_hint (cast frame (@ {self}))
(obj_getstr {$var})) } }
View
2 t/spectest.data
@@ -72,6 +72,7 @@ S05-metasyntax/changed.t
S05-metasyntax/null.t
S05-metasyntax/single-quotes.t
S06-multi/lexical-multis.t
+S06-advanced_subroutine_features/caller.t
S06-signature/passing-arrays.t
S06-signature/positional-placeholders.t
S06-signature/positional.t
@@ -98,6 +99,7 @@ S32-array/bool.t
S32-array/push.t
S32-array/unshift.t
S32-hash/pairs.t
+S32-num/pi.t
S32-num/power.t
S32-str/append.t
S32-str/bool.t

0 comments on commit f5a1f34

Please sign in to comment.