Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement @*ARGS
  • Loading branch information
sorear committed Nov 16, 2010
1 parent 626548d commit c135903
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/CORE.setting
Expand Up @@ -34,5 +34,6 @@ my class TextReader is IO {
}
$PROCESS::IN ::= Q:CgOp { (box TextReader (treader_stdin)) };
@PROCESS::ARGS ::= [ unitem(Q:CgOp { (box Parcel (getargv)) }) ];
{YOU_ARE_HERE}
9 changes: 9 additions & 0 deletions lib/Kernel.cs
Expand Up @@ -924,6 +924,15 @@ public class Kernel {
return lv;
}

public static string[] commandArgs;
public static Variable[] ArgsHelper() {
List<Variable> lv = new List<Variable>();
foreach (string s in commandArgs) {
lv.Add(BoxAny(s, StrP));
}
return lv.ToArray();
}

public static VarDeque SortHelper(Frame th, IP6 cb, VarDeque from) {
Variable[] tmp = from.CopyAsArray();
Array.Sort(tmp, delegate (Variable v1, Variable v2) {
Expand Down
3 changes: 2 additions & 1 deletion src/CSharpBackend.pm
Expand Up @@ -78,7 +78,8 @@ using System.Collections.Generic;
public class ${\ $unit->name } {
EOH
$mod .= <<EOM unless $libmode ;
public static void Main() {
public static void Main(string[] argv) {
Kernel.commandArgs = argv;
Kernel.RunLoop(new SubInfo("boot", BOOT));
}
Expand Down
1 change: 1 addition & 0 deletions src/CgOp.pm
Expand Up @@ -176,6 +176,7 @@ use warnings;
sub exit { rawscall('System.Environment.Exit', $_[0]) }
sub slurp { rawscall('System.IO.File.ReadAllText', $_[0]) }
sub spew { rawscall('System.IO.File.WriteAllText:m,Void', $_[0], $_[1]) }
sub getargv { rawscall('Kernel.ArgsHelper:m,Variable[]') }

sub treader_getc { rawcall($_[0], 'Read:m,Int32') }
sub treader_slurp { rawcall($_[0], 'ReadToEnd:m,String') }
Expand Down

0 comments on commit c135903

Please sign in to comment.