Skip to content

Commit

Permalink
asCode method writes patternproxies with source; printOn posts Tdef, …
Browse files Browse the repository at this point in the history
…Pdef, Pdefn with their name.
  • Loading branch information
adc committed May 14, 2011
1 parent ebf9e22 commit 46f4921
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions SCClassLibrary/JITLib/Patterns/extPostAsCode.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
+ PatternProxy {
// like asCompileString, but with full source etc.
asCode {
var mykey = this.key.asCompileString;
var str; str = "" ++ this.class.name ++ "(";

if(source.isNil or: { source == this.class.default }) {
str = str ++ mykey;
} {
str = str ++ this.repositoryArgs.asCompileString.drop(1).drop(-1);
};
str = str ++ ")";

if(this.envir.notNil and: { this.envir.notEmpty }) {
str = str ++ ".set(" ++
this.envir.asKeyValuePairs.asCompileString.drop(1).drop(-1) ++ ")"
};
str = str ++ ";"
^str
}
}

+ Tdef {
printOn { |stream|
^this.storeOn(stream);
}
}
+ Pdef {
printOn { |stream|
^this.storeOn(stream);
}
}
+ Pdefn {
printOn { |stream|
^this.storeOn(stream);
}
}

0 comments on commit 46f4921

Please sign in to comment.