Permalink
Browse files

[java] add definedness and defaultValue arguments to Parameter constr…

…uctor
  • Loading branch information...
1 parent b3bdc96 commit a6a9a497f87ef3405a62d5b40c7971803f2ca58a @mberends mberends committed Jan 25, 2011
Showing with 16 additions and 14 deletions.
  1. +8 −7 java/compiler/PAST2JSTCompiler.pm
  2. +8 −7 java/runtime/Rakudo/Runtime/Parameter.java
View
15 java/compiler/PAST2JSTCompiler.pm
@@ -183,6 +183,7 @@ method compile(PAST::Node $node) {
JST::Using.new( :namespace('Rakudo.Metamodel.REPRRegistry') ),
JST::Using.new( :namespace('Rakudo.Runtime.CaptureHelper') ),
JST::Using.new( :namespace('Rakudo.Runtime.CodeObjectUtility') ),
+ JST::Using.new( :namespace('Rakudo.Runtime.DefinednessConstraint') ),
JST::Using.new( :namespace('Rakudo.Runtime.Context') ),
JST::Using.new( :namespace('Rakudo.Runtime.Ops') ),
JST::Using.new( :namespace('Rakudo.Runtime.Parameter') ),
@@ -537,14 +538,14 @@ sub compile_signature(@params) {
'Parameter.POS_FLAG');
# Definedness constraint.
-# TODO $param.push($_<definedness> eq 'D' ?? 'DefinednessConstraint.DefinedOnly' !!
-# $_<definedness> eq 'U' ?? 'DefinednessConstraint.UndefinedOnly' !!
-# 'DefinednessConstraint.None');
-
+ $param.push($_<definedness> eq 'D' ?? 'DefinednessConstraint.DefinedOnly' !!
+ $_<definedness> eq 'U' ?? 'DefinednessConstraint.UndefinedOnly' !!
+ 'DefinednessConstraint.None');
+
# viviself.
-# TODO $param.push($_.viviself ~~ PAST::Node
-# ?? jst_for(PAST::Block.new(:closure(1), $_.viviself))
-# !! JST::Null.new());
+ $param.push($_.viviself ~~ PAST::Node
+ ?? jst_for(PAST::Block.new(:closure(1), $_.viviself))
+ !! JST::Null.new());
$params.push($param);
}
View
15 java/runtime/Rakudo/Runtime/Parameter.java
@@ -18,19 +18,16 @@
/// <param name="VariableName"></param>
/// <param name="Name"></param>
/// <param name="Flags"></param>
-// public Parameter(RakudoObject type, String variableName, int variableLexpadPosition,
-// String name, int flags, DefinednessConstraint definedness, RakudoObject defaultValue)
public Parameter(RakudoObject type, String variableName, int variableLexpadPosition,
- String name, int flags)
+ String name, int flags, DefinednessConstraint definedness, RakudoObject defaultValue)
{
this.Type = type;
this.VariableName = variableName;
this.VariableLexpadPosition = variableLexpadPosition;
this.Name = name;
-// TODO this.DefaultValue = defaultValue;
+ this.DefaultValue = defaultValue;
this.Flags = flags;
-// TODO this.Definedness = definedness;
- this.Definedness = DefinednessConstraint.None;
+ this.Definedness = definedness;
}
/// <summary>
@@ -71,7 +68,7 @@ public Parameter(RakudoObject type, String variableName, int variableLexpadPosit
/// <summary>
/// (Un-)flag for positional parameters.
/// </summary>
- public static final int POS_FLAG = 0;
+ public static final int POS_FLAG = 0; // C# has public const int
/// <summary>
/// Flag for optional parameters.
@@ -93,6 +90,10 @@ public Parameter(RakudoObject type, String variableName, int variableLexpadPosit
/// </summary>
public static final int NAMED_FLAG = 8;
+ /// <summary>
+ /// Tests whether the flag is optional.
+ /// </summary>
+ /// <returns></returns>
public boolean IsOptional()
{
return (Flags & OPTIONAL_FLAG) > 0;

0 comments on commit a6a9a49

Please sign in to comment.