Skip to content

Commit

Permalink
[jvm] Remove leading and trailing whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
usev6 committed Jan 2, 2018
1 parent 8fd776f commit 00b7832
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 108 deletions.
80 changes: 40 additions & 40 deletions src/vm/jvm/runtime/org/perl6/rakudo/Binder.java
Expand Up @@ -16,12 +16,12 @@ public final class Binder {
public static final int BIND_RESULT_OK = 0;
public static final int BIND_RESULT_FAIL = 1;
public static final int BIND_RESULT_JUNCTION = 2;

/* Compile time trial binding result indicators. */
public static final int TRIAL_BIND_NOT_SURE = 0; /* Plausible, but need to check at runtime. */
public static final int TRIAL_BIND_OK = 1; /* Bind will always work out. */
public static final int TRIAL_BIND_NO_WAY = -1; /* Bind could never work out. */

/* Flags. */
private static final int SIG_ELEM_BIND_CAPTURE = 1;
private static final int SIG_ELEM_BIND_PRIVATE_ATTR = 2;
Expand Down Expand Up @@ -51,7 +51,7 @@ public final class Binder {
private static final int SIG_ELEM_NATIVE_VALUE = (SIG_ELEM_NATIVE_INT_VALUE | SIG_ELEM_NATIVE_NUM_VALUE | SIG_ELEM_NATIVE_STR_VALUE);
private static final int SIG_ELEM_SLURPY_ONEARG = 16777216;
private static final int SIG_ELEM_SLURPY = (SIG_ELEM_SLURPY_POS | SIG_ELEM_SLURPY_NAMED | SIG_ELEM_SLURPY_LOL | SIG_ELEM_SLURPY_ONEARG);

/* Hints for Parameter attributes. */
private static final int HINT_variable_name = 0;
private static final int HINT_named_names = 1;
Expand All @@ -65,7 +65,7 @@ public final class Binder {
private static final int HINT_default_value = 9;
private static final int HINT_container_descriptor = 10;
private static final int HINT_attr_package = 11;

/* Other hints. */
private static final int HINT_ENUMMAP_storage = 0;
private static final int HINT_CAPTURE_list = 0;
Expand All @@ -85,7 +85,7 @@ private static SixModelObject createBox(ThreadContext tc, RakOps.GlobalExt gcx,
throw new RuntimeException("Impossible case reached in createBox");
}
}

private static String arityFail(ThreadContext tc, RakOps.GlobalExt gcx, SixModelObject params,
int numParams, int numPosArgs, boolean tooMany) {
int arity = 0;
Expand Down Expand Up @@ -130,7 +130,7 @@ else if (count <= -1)
"%s positionals passed; expected %d %s %d arguments but got %d",
fail, arity, arity + 1 == count ? "or" : "to" , count, numPosArgs);
}

/* Binds any type captures. */
public static void bindTypeCaptures(ThreadContext tc, SixModelObject typeCaps, CallFrame cf, SixModelObject type) {
long elems = typeCaps.elems(tc);
Expand All @@ -141,7 +141,7 @@ public static void bindTypeCaptures(ThreadContext tc, SixModelObject typeCaps, C
cf.oLex[sci.oTryGetLexicalIdx(name)] = type;
}
}

/* Assigns an attributive parameter to the desired attribute. */
private static int assignAttributive(ThreadContext tc, CallFrame cf, String varName,
int paramFlags, SixModelObject attrPackage, SixModelObject value, Object[] error) {
Expand All @@ -166,7 +166,7 @@ private static int assignAttributive(ThreadContext tc, CallFrame cf, String varN
/* If it's private, just need to fetch the attribute. */
SixModelObject assignee;
if ((paramFlags & SIG_ELEM_BIND_PRIVATE_ATTR) != 0) {
/* If we have a native Attribute we can't get a container for it, and
/* If we have a native Attribute we can't get a container for it, and
since *trying* to get a container would throw already, we first check
if the target Attribute is native. */
int hint = -1;
Expand Down Expand Up @@ -204,15 +204,15 @@ else if (attrREPR instanceof P6str) {
}
return BIND_RESULT_OK;
}

/* Returns an appropriate failure mode (junction fail or normal fail). */
private static int juncOrFail(ThreadContext tc, RakOps.GlobalExt gcx, SixModelObject value) {
if (value.st.WHAT == gcx.Junction && Ops.isconcrete(value, tc) != 0)
return BIND_RESULT_JUNCTION;
else
return BIND_RESULT_FAIL;
}

/* Binds a single argument into the lexpad, after doing any checks that are
* needed. Also handles any type captures. If there is a sub signature, then
* re-enters the binder. Returns one of the BIND_RESULT_* codes. */
Expand Down Expand Up @@ -251,15 +251,15 @@ private static int bindOneParam(ThreadContext tc, RakOps.GlobalExt gcx, CallFram
}
if (RakOps.DEBUG_MODE)
System.err.println(varName);

/* We'll put the value to bind into one of the following locals, and
* flag will indicate what type of thing it is. */
int flag;
long arg_i = 0;
double arg_n = 0.0;
String arg_s = null;
SixModelObject arg_o = null;

/* Check if boxed/unboxed expectations are met. */
int desiredNative = paramFlags & SIG_ELEM_NATIVE_VALUE;
boolean is_rw = (paramFlags & SIG_ELEM_IS_RW) != 0;
Expand Down Expand Up @@ -370,7 +370,7 @@ else if (desiredNative == 0) {
return BIND_RESULT_FAIL;
}
}

/* By this point, we'll either have an object that we might be able to
* bind if it passes the type check, or a native value that needs no
* further checking. */
Expand All @@ -380,13 +380,13 @@ else if (desiredNative == 0) {
if (flag == CallSiteDescriptor.ARG_OBJ && !(is_rw && desiredNative != 0)) {
/* We need to work on the decontainerized value. */
decontValue = Ops.decont(arg_o, tc);

/* HLL map it as needed. */
SixModelObject beforeHLLize = decontValue;
decontValue = Ops.hllize(decontValue, tc);
if (decontValue != beforeHLLize)
didHLLTransform = true;

/* Skip nominal type check if not needed. */
if (!noNomTypeCheck) {
/* Is the nominal type generic and in need of instantiation? (This
Expand Down Expand Up @@ -441,7 +441,7 @@ else if (Ops.istype_nodecont(decontValue, gcx.PositionalBindFailover, tc) != 0)
varName);
}
}

/* Report junction failure mode if it's a junction. */
return juncOrFail(tc, gcx, decontValue);
}
Expand Down Expand Up @@ -491,13 +491,13 @@ else if (Ops.istype_nodecont(decontValue, gcx.PositionalBindFailover, tc) != 0)
}
}
}

/* Type captures. */
SixModelObject typeCaps = param.get_attribute_boxed(tc, gcx.Parameter,
"@!type_captures", HINT_type_captures);
if (typeCaps != null)
bindTypeCaptures(tc, typeCaps, cf, decontValue.st.WHAT);

/* Do a coercion, if one is needed. */
SixModelObject coerceType = param.get_attribute_boxed(tc, gcx.Parameter,
"$!coerce_type", HINT_coerce_type);
Expand All @@ -510,7 +510,7 @@ else if (Ops.istype_nodecont(decontValue, gcx.PositionalBindFailover, tc) != 0)
varName);
return BIND_RESULT_FAIL;
}

/* Only coerce if we don't already have the correct type. */
if (Ops.istype(decontValue, coerceType, tc) == 0) {
param.get_attribute_native(tc, gcx.Parameter, "$!coerce_method", HINT_coerce_method);
Expand All @@ -532,7 +532,7 @@ else if (Ops.istype_nodecont(decontValue, gcx.PositionalBindFailover, tc) != 0)
}
}
}

/* If it's not got attributive binding, we'll go about binding it into the
* lex pad. */
StaticCodeInfo sci = cf.codeRef.staticInfo;
Expand All @@ -553,7 +553,7 @@ else if (Ops.istype_nodecont(decontValue, gcx.PositionalBindFailover, tc) != 0)
}
}
}

/* Otherwise it's some objecty case. */
else if (is_rw) {
if (Ops.isrwcont(arg_o, tc) == 1) {
Expand Down Expand Up @@ -633,7 +633,7 @@ else if ((paramFlags & SIG_ELEM_HASH_SIGIL) != 0) {
}
}
}

/* Is it the invocant? If so, also have to bind to self lexical. */
if ((paramFlags & SIG_ELEM_INVOCANT) != 0)
cf.oLex[sci.oTryGetLexicalIdx("self")] = decontValue;
Expand Down Expand Up @@ -735,7 +735,7 @@ else if ((paramFlags & SIG_ELEM_HASH_SIGIL) != 0) {

if (RakOps.DEBUG_MODE)
System.err.println("bindOneParam NYFI");

return BIND_RESULT_OK;
}

Expand Down Expand Up @@ -803,7 +803,7 @@ else if ((flags & SIG_ELEM_HASH_SIGIL) != 0) {
}
}
}

/* Takes a signature along with positional and named arguments and binds them
* into the provided callframe. Returns BIND_RESULT_OK if binding works out,
* BIND_RESULT_FAIL if there is a failure and BIND_RESULT_JUNCTION if the
Expand All @@ -815,19 +815,19 @@ public static int bind(ThreadContext tc, RakOps.GlobalExt gcx, CallFrame cf, Six
boolean noNomTypeCheck, Object[] error) {
int bindFail = BIND_RESULT_OK;
int curPosArg = 0;

/* If we have a |$foo that's followed by slurpies, then we can suppress
* any future arity checks. */
boolean suppressArityFail = false;

/* If we do have some named args, we want to make a clone of the hash
* to work on. We'll delete stuff from it as we bind, and what we have
* left over can become the slurpy hash or - if we aren't meant to be
* taking one - tell us we have a problem. */
HashMap<String, Integer> namedArgsCopy = csd.nameMap == null
? null
: new HashMap<String, Integer>(csd.nameMap);

/* Now we'll walk through the signature and go about binding things. */
int numPosArgs = csd.numPositionals;
long numParams = params.elems(tc);
Expand All @@ -838,7 +838,7 @@ public static int bind(ThreadContext tc, RakOps.GlobalExt gcx, CallFrame cf, Six
int flags = (int)tc.native_i;
SixModelObject namedNames = param.get_attribute_boxed(tc,
gcx.Parameter, "@!named_names", HINT_named_names);

/* Is it looking for us to bind a capture here? */
if ((flags & SIG_ELEM_IS_CAPTURE) != 0) {
/* Capture the arguments from this point forwards into a Capture.
Expand All @@ -865,16 +865,16 @@ public static int bind(ThreadContext tc, RakOps.GlobalExt gcx, CallFrame cf, Six
posArgs.push_boxed(tc, RakOps.p6box_s((String)args[k], tc));
break;
}
}
}
SixModelObject namedArgs = vmHashOfRemainingNameds(tc, gcx, namedArgsCopy, args);

SixModelObject capType = gcx.Capture;
SixModelObject capSnap = capType.st.REPR.allocate(tc, capType.st);
capSnap.bind_attribute_boxed(tc, capType, "@!list", HINT_CAPTURE_list, posArgs);
capSnap.bind_attribute_boxed(tc, capType, "%!hash", HINT_CAPTURE_hash, namedArgs);

bindFail = bindOneParam(tc, gcx, cf, param, capSnap, CallSiteDescriptor.ARG_OBJ,
noNomTypeCheck, error);
noNomTypeCheck, error);
}
if (bindFail != 0) {
return bindFail;
Expand All @@ -892,7 +892,7 @@ else if (i + 1 == numParams) {
suppressArityFail = true;
}
}

/* Could it be a named slurpy? */
else if ((flags & SIG_ELEM_SLURPY_NAMED) != 0) {
SixModelObject slurpy = vmHashOfRemainingNameds(tc, gcx, namedArgsCopy, args);
Expand All @@ -903,12 +903,12 @@ else if ((flags & SIG_ELEM_SLURPY_NAMED) != 0) {
noNomTypeCheck, error);
if (bindFail != 0)
return bindFail;

/* Nullify named arguments hash now we've consumed it, to mark all
* is well. */
namedArgsCopy = null;
}

/* Otherwise, maybe it's a positional of some kind. */
else if (namedNames == null) {
/* Slurpy or LoL-slurpy? */
Expand Down Expand Up @@ -947,7 +947,7 @@ else if (namedNames == null) {
if (bindFail != 0)
return bindFail;
}

/* Otherwise, a positional. */
else {
/* Do we have a value?. */
Expand Down Expand Up @@ -978,7 +978,7 @@ else if (namedNames == null) {
}
}
}

/* Else, it's a non-slurpy named. */
else {
/* Try and get hold of value. */
Expand All @@ -993,7 +993,7 @@ else if (namedNames == null) {
break;
}
}

/* Did we get one? */
if (lookup == null) {
/* Nope. We'd better hope this param was optional... */
Expand Down Expand Up @@ -1022,7 +1022,7 @@ else if (!suppressArityFail) {
return bindFail;
}
}

/* Do we have any left-over args? */
if (curPosArg < numPosArgs && !suppressArityFail) {
/* Oh noes, too many positionals passed. */
Expand Down Expand Up @@ -1057,7 +1057,7 @@ else if (!suppressArityFail) {
/* If we get here, we're done. */
return BIND_RESULT_OK;
}

/* Takes any nameds we didn't capture yet and makes a VM Hash of them. */
private static SixModelObject vmHashOfRemainingNameds(ThreadContext tc, RakOps.GlobalExt gcx, HashMap<String, Integer> namedArgsCopy, Object[] args) {
SixModelObject slurpy = gcx.Mu;
Expand Down

0 comments on commit 00b7832

Please sign in to comment.