Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:jnthn/6model
  • Loading branch information
diakopter committed Nov 17, 2010
2 parents 39ec4ec + 021ee7e commit 64f1a9c
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 91 deletions.
33 changes: 28 additions & 5 deletions dotnet/LHF.txt
Expand Up @@ -6,9 +6,32 @@ you want to start hacking on the 6model implementation on .Net, this
is a great way to jump in! Questions? Try catching jnthn on #perl6
on freenode.

String comparative operators
----------------------------
DIFFICULTY: Intermediate-Impossible
SKILLS: Being jnthn
Support for has $.foo to classes
--------------------------------
DIFFICULTY: Intermediate-Difficult
SKILLS: NQP
DETAILS:
Add task items to this file.
Add a has_accessor attribute and accessor methods to the NQPAttribute
knowhow. Take a :$has_accessor in the new method and set it (use a
default value of 0 for if nothing is passed). Update Grammar.pm to know
about the $.foo twigil. Update Actions.pm to pass along the has_accessor
named parameter when the . twigil is used. Note that the attribute
itself should be named $!foo - $.foo is just sugar for "declare $!foo
and make me an accessor method". Add a .compose method to NQPAttribute.
It should take a type-object of the class it's being composed into as
a parameter. In NQPClassHOW's compose method, loop over the attributes
and call .compose on them. Finally, fill out the compose method in
NQPAttribute. It should add a method that does the attribute lookup.
Something like:

method compose($obj) {
my $name := $!name;
$obj.HOW.add_method($obj, $name, method () {
nqp::get_attr(self, $obj.WHAT, $name)
});
}

(Yes, the named lookup sucks for now, but soon we'll have enough to put
an indexed lookup there instead. But let's make this work first.)


144 changes: 72 additions & 72 deletions dotnet/runtime/Runtime/Ops/Primitive.cs
Expand Up @@ -130,78 +130,78 @@ public static RakudoObject mul_num(ThreadContext TC, RakudoObject x, RakudoObjec
public static RakudoObject div_num(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_num(TC, Ops.unbox_num(TC, x) / Ops.unbox_num(TC, y), TC.DefaultNumBoxType);
}

/// <summary>
/// Performs a bitwise or on ints.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_or_int(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_int(TC, Ops.unbox_int(TC, x) | Ops.unbox_int(TC, y), TC.DefaultIntBoxType);
}

/// <summary>
/// Performs a bitwise and on ints.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_and_int(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_int(TC, Ops.unbox_int(TC, x) & Ops.unbox_int(TC, y), TC.DefaultIntBoxType);
}

/// <summary>
/// Performs a bitwise xor on ints.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_xor_int(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_int(TC, Ops.unbox_int(TC, x) ^ Ops.unbox_int(TC, y), TC.DefaultIntBoxType);
}

/// <summary>
/// Performs a bitwise or on nums.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_or_num(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_num(TC, BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, x)) | BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, y))), TC.DefaultNumBoxType);
}

/// <summary>
/// Performs a bitwise and on nums.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_and_num(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_num(TC, BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, x)) & BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, y))), TC.DefaultNumBoxType);
}

/// <summary>
/// Performs a bitwise xor on nums.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_xor_num(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_num(TC, BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, x)) ^ BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, y))), TC.DefaultNumBoxType);
}

/// <summary>
/// Performs a bitwise or on ints.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_or_int(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_int(TC, Ops.unbox_int(TC, x) | Ops.unbox_int(TC, y), TC.DefaultIntBoxType);
}

/// <summary>
/// Performs a bitwise and on ints.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_and_int(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_int(TC, Ops.unbox_int(TC, x) & Ops.unbox_int(TC, y), TC.DefaultIntBoxType);
}

/// <summary>
/// Performs a bitwise xor on ints.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_xor_int(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_int(TC, Ops.unbox_int(TC, x) ^ Ops.unbox_int(TC, y), TC.DefaultIntBoxType);
}

/// <summary>
/// Performs a bitwise or on nums.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_or_num(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_num(TC, BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, x)) | BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, y))), TC.DefaultNumBoxType);
}

/// <summary>
/// Performs a bitwise and on nums.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_and_num(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_num(TC, BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, x)) & BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, y))), TC.DefaultNumBoxType);
}

/// <summary>
/// Performs a bitwise xor on nums.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="ResultType"></param>
/// <returns></returns>
public static RakudoObject bitwise_xor_num(ThreadContext TC, RakudoObject x, RakudoObject y)
{
return Ops.box_num(TC, BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, x)) ^ BitConverter.DoubleToInt64Bits(Ops.unbox_num(TC, y))), TC.DefaultNumBoxType);
}

/// <summary>
Expand Down
24 changes: 12 additions & 12 deletions dotnet/runtime/Runtime/Signatures/Parameter.cs
Expand Up @@ -24,7 +24,7 @@ public class Parameter
this.Type = Type;
this.VariableName = VariableName;
this.VariableLexpadPosition = VariableLexpadPosition;
this.Name = Name;
this.Name = Name;
this.DefaultValue = DefaultValue;
this.Flags = Flags;
this.Definedness = Definedness;
Expand Down Expand Up @@ -52,12 +52,12 @@ public class Parameter

/// <summary>
/// Name, for named parameters.
/// </summary>
public string Name;

/// <summary>
/// Default RakudoObject for optional parameters.
/// </summary>
/// </summary>
public string Name;

/// <summary>
/// Default RakudoObject for optional parameters.
/// </summary>
public RakudoObject DefaultValue;

/// <summary>
Expand Down Expand Up @@ -88,11 +88,11 @@ public class Parameter
/// <summary>
/// Flag for named parameters.
/// </summary>
public const int NAMED_FLAG = 8;

public bool IsOptional()
{
return (Flags ^ OPTIONAL_FLAG) > 0;
public const int NAMED_FLAG = 8;

public bool IsOptional()
{
return (Flags ^ OPTIONAL_FLAG) > 0;
}
}
}
4 changes: 2 additions & 2 deletions dotnet/runtime/Runtime/Signatures/SignatureBinder.cs
Expand Up @@ -90,8 +90,8 @@ public static void Bind(ThreadContext TC, Context C, RakudoObject Capture)
}
else
{
// Default value, vivification.
// ((RakudoCodeRef.Instance)Param.DefaultValue).CurrentContext = TC.CurrentContext;
// Default value, vivification.
// ((RakudoCodeRef.Instance)Param.DefaultValue).CurrentContext = TC.CurrentContext;
C.LexPad.Storage[Param.VariableLexpadPosition] = Param.DefaultValue.STable.Invoke(TC, Param.DefaultValue, Capture);
}
}
Expand Down

0 comments on commit 64f1a9c

Please sign in to comment.