[noop] push by aeagle22206 - nearly compiling again, need to think aboumore about modelling unit te... on 2009-12-11 08:03 GMT

1 view
Skip to first unread message

no...@googlecode.com

unread,
Dec 11, 2009, 3:04:14 AM12/11/09
to noop-c...@googlegroups.com
Revision: 50cd360eb6
Author: Alex Eagle <aeagl...@gmail.com>
Date: Fri Dec 11 00:03:26 2009
Log: nearly compiling again, need to think aboumore about modelling unit
tests
http://code.google.com/p/noop/source/detail?r=50cd360eb6

Added:
/core/src/main/scala/noop/model/UnittestDefinition.scala
Deleted:
/core/src/main/scala/noop/model/Modifier.scala
Modified:
/core/src/main/java/noop/model/proto/Noop.java
/core/src/main/proto/noop.proto
/core/src/main/scala/noop/model/BindingDeclaration.scala
/core/src/main/scala/noop/model/BindingDefinition.scala
/core/src/main/scala/noop/model/Block.scala
/core/src/main/scala/noop/model/ClassDefinition.scala
/core/src/main/scala/noop/model/ConcreteClassDefinition.scala
/core/src/main/scala/noop/model/ExpressionConverter.scala
/core/src/main/scala/noop/model/InterfaceDefinition.scala
/core/src/main/scala/noop/model/LoggingAstVisitor.scala
/core/src/main/scala/noop/model/MethodDefinition.scala
/core/src/main/scala/noop/model/Module.scala
/core/src/main/scala/noop/types/NoopObject.scala
/core/src/test/java/noop/model/proto/ProtoBufferSpike.java
/interpreter/src/main/scala/noop/inject/GuiceBackedInjector.scala
/interpreter/src/main/scala/noop/interpreter/ClassLoader.scala
/interpreter/src/main/scala/noop/interpreter/ClassSearch.scala
/interpreter/src/main/scala/noop/interpreter/Interpreter.scala
/interpreter/src/main/scala/noop/interpreter/InterpreterVisitor.scala

/interpreter/src/main/scala/noop/interpreter/MethodInvocationEvaluator.scala
/interpreter/src/main/scala/noop/interpreter/SourceFileClassLoader.scala
/interpreter/src/main/scala/noop/interpreter/testing/TestHolder.scala
/interpreter/src/main/scala/noop/interpreter/testing/TestRunner.scala

=======================================
--- /dev/null
+++ /core/src/main/scala/noop/model/UnittestDefinition.scala Fri Dec 11
00:03:26 2009
@@ -0,0 +1,9 @@
+package noop.model
+
+import proto.Noop.Unittest
+
+/**
+ * @author alex...@google.com (Alex Eagle)
+ */
+
+class UnittestDefinition(val data: Unittest)
=======================================
--- /core/src/main/scala/noop/model/Modifier.scala Thu Oct 8 10:25:57 2009
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright 2009 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package noop.model;
-
-/**
- * @author alex...@google.com (Alex Eagle)
- */
-object Modifier extends Enumeration {
-
- type Modifier = Value;
- val native = Value("native");
- val mutable = Value("mutable");
- val delegate = Value("delegate");
-}
=======================================
--- /core/src/main/java/noop/model/proto/Noop.java Thu Dec 10 22:06:44 2009
+++ /core/src/main/java/noop/model/proto/Noop.java Fri Dec 11 00:03:26 2009
@@ -10,6 +10,7 @@
public enum Modifier
implements com.google.protobuf.ProtocolMessageEnum {
MUTABLE(0, 1),
+ NATIVE(1, 2),
;


@@ -18,6 +19,7 @@
public static Modifier valueOf(int value) {
switch (value) {
case 1: return MUTABLE;
+ case 2: return NATIVE;
default: return null;
}
}
@@ -48,7 +50,7 @@
}

private static final Modifier[] VALUES = {
- MUTABLE,
+ MUTABLE, NATIVE,
};
public static Modifier valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
@@ -3095,8 +3097,20 @@
public boolean hasDocumentation() { return hasDocumentation; }
public java.lang.String getDocumentation() { return documentation_; }

- // repeated string return_type = 3;
- public static final int RETURN_TYPE_FIELD_NUMBER = 3;
+ // repeated .Modifier modifier = 3;
+ public static final int MODIFIER_FIELD_NUMBER = 3;
+ private java.util.List<noop.model.proto.Noop.Modifier> modifier_ =
+ java.util.Collections.emptyList();
+ public java.util.List<noop.model.proto.Noop.Modifier>
getModifierList() {
+ return modifier_;
+ }
+ public int getModifierCount() { return modifier_.size(); }
+ public noop.model.proto.Noop.Modifier getModifier(int index) {
+ return modifier_.get(index);
+ }
+
+ // repeated string return_type = 4;
+ public static final int RETURN_TYPE_FIELD_NUMBER = 4;
private java.util.List<java.lang.String> returnType_ =
java.util.Collections.emptyList();
public java.util.List<java.lang.String> getReturnTypeList() {
@@ -3107,8 +3121,8 @@
return returnType_.get(index);
}

- // repeated .Property argument = 4;
- public static final int ARGUMENT_FIELD_NUMBER = 4;
+ // repeated .Property argument = 5;
+ public static final int ARGUMENT_FIELD_NUMBER = 5;
private java.util.List<noop.model.proto.Noop.Property> argument_ =
java.util.Collections.emptyList();
public java.util.List<noop.model.proto.Noop.Property>
getArgumentList() {
@@ -3135,11 +3149,14 @@
if (hasDocumentation()) {
output.writeString(2, getDocumentation());
}
+ for (noop.model.proto.Noop.Modifier element : getModifierList()) {
+ output.writeEnum(3, element.getNumber());
+ }
for (java.lang.String element : getReturnTypeList()) {
- output.writeString(3, element);
+ output.writeString(4, element);
}
for (noop.model.proto.Noop.Property element : getArgumentList()) {
- output.writeMessage(4, element);
+ output.writeMessage(5, element);
}
getUnknownFields().writeTo(output);
}
@@ -3158,6 +3175,15 @@
size += com.google.protobuf.CodedOutputStream
.computeStringSize(2, getDocumentation());
}
+ {
+ int dataSize = 0;
+ for (noop.model.proto.Noop.Modifier element : getModifierList()) {
+ dataSize += com.google.protobuf.CodedOutputStream
+ .computeEnumSizeNoTag(element.getNumber());
+ }
+ size += dataSize;
+ size += 1 * getModifierList().size();
+ }
{
int dataSize = 0;
for (java.lang.String element : getReturnTypeList()) {
@@ -3169,7 +3195,7 @@
}
for (noop.model.proto.Noop.Property element : getArgumentList()) {
size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(4, element);
+ .computeMessageSize(5, element);
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@@ -3304,6 +3330,10 @@
throw new IllegalStateException(
"build() has already been called on this Builder.");
}
+ if (result.modifier_ != java.util.Collections.EMPTY_LIST) {
+ result.modifier_ =
+ java.util.Collections.unmodifiableList(result.modifier_);
+ }
if (result.returnType_ != java.util.Collections.EMPTY_LIST) {
result.returnType_ =
java.util.Collections.unmodifiableList(result.returnType_);
@@ -3334,6 +3364,12 @@
if (other.hasDocumentation()) {
setDocumentation(other.getDocumentation());
}
+ if (!other.modifier_.isEmpty()) {
+ if (result.modifier_.isEmpty()) {
+ result.modifier_ = new
java.util.ArrayList<noop.model.proto.Noop.Modifier>();
+ }
+ result.modifier_.addAll(other.modifier_);
+ }
if (!other.returnType_.isEmpty()) {
if (result.returnType_.isEmpty()) {
result.returnType_ = new
java.util.ArrayList<java.lang.String>();
@@ -3379,11 +3415,21 @@
setDocumentation(input.readString());
break;
}
- case 26: {
- addReturnType(input.readString());
+ case 24: {
+ int rawValue = input.readEnum();
+ noop.model.proto.Noop.Modifier value =
noop.model.proto.Noop.Modifier.valueOf(rawValue);
+ if (value == null) {
+ unknownFields.mergeVarintField(3, rawValue);
+ } else {
+ addModifier(value);
+ }
break;
}
case 34: {
+ addReturnType(input.readString());
+ break;
+ }
+ case 42: {
noop.model.proto.Noop.Property.Builder subBuilder =
noop.model.proto.Noop.Property.newBuilder();
input.readMessage(subBuilder, extensionRegistry);
addArgument(subBuilder.buildPartial());
@@ -3436,7 +3482,47 @@
return this;
}

- // repeated string return_type = 3;
+ // repeated .Modifier modifier = 3;
+ public java.util.List<noop.model.proto.Noop.Modifier>
getModifierList() {
+ return java.util.Collections.unmodifiableList(result.modifier_);
+ }
+ public int getModifierCount() {
+ return result.getModifierCount();
+ }
+ public noop.model.proto.Noop.Modifier getModifier(int index) {
+ return result.getModifier(index);
+ }
+ public Builder setModifier(int index, noop.model.proto.Noop.Modifier
value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.modifier_.set(index, value);
+ return this;
+ }
+ public Builder addModifier(noop.model.proto.Noop.Modifier value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ if (result.modifier_.isEmpty()) {
+ result.modifier_ = new
java.util.ArrayList<noop.model.proto.Noop.Modifier>();
+ }
+ result.modifier_.add(value);
+ return this;
+ }
+ public Builder addAllModifier(
+ java.lang.Iterable<? extends noop.model.proto.Noop.Modifier>
values) {
+ if (result.modifier_.isEmpty()) {
+ result.modifier_ = new
java.util.ArrayList<noop.model.proto.Noop.Modifier>();
+ }
+ super.addAll(values, result.modifier_);
+ return this;
+ }
+ public Builder clearModifier() {
+ result.modifier_ = java.util.Collections.emptyList();
+ return this;
+ }
+
+ // repeated string return_type = 4;
public java.util.List<java.lang.String> getReturnTypeList() {
return java.util.Collections.unmodifiableList(result.returnType_);
}
@@ -3476,7 +3562,7 @@
return this;
}

- // repeated .Property argument = 4;
+ // repeated .Property argument = 5;
public java.util.List<noop.model.proto.Noop.Property>
getArgumentList() {
return java.util.Collections.unmodifiableList(result.argument_);
}
@@ -4243,17 +4329,17 @@
public boolean hasType() { return hasType; }
public java.lang.String getType() { return type_; }

- // required .Expression to = 2;
- public static final int TO_FIELD_NUMBER = 2;
- private boolean hasTo;
- private noop.model.proto.Noop.Expression to_ =
noop.model.proto.Noop.Expression.getDefaultInstance();
- public boolean hasTo() { return hasTo; }
- public noop.model.proto.Noop.Expression getTo() { return to_; }
+ // required .Expression boundTo = 2;
+ public static final int BOUNDTO_FIELD_NUMBER = 2;
+ private boolean hasBoundTo;
+ private noop.model.proto.Noop.Expression boundTo_ =
noop.model.proto.Noop.Expression.getDefaultInstance();
+ public boolean hasBoundTo() { return hasBoundTo; }
+ public noop.model.proto.Noop.Expression getBoundTo() { return
boundTo_; }

public final boolean isInitialized() {
if (!hasType) return false;
- if (!hasTo) return false;
- if (!getTo().isInitialized()) return false;
+ if (!hasBoundTo) return false;
+ if (!getBoundTo().isInitialized()) return false;
return true;
}

@@ -4262,8 +4348,8 @@
if (hasType()) {
output.writeString(1, getType());
}
- if (hasTo()) {
- output.writeMessage(2, getTo());
+ if (hasBoundTo()) {
+ output.writeMessage(2, getBoundTo());
}
getUnknownFields().writeTo(output);
}
@@ -4278,9 +4364,9 @@
size += com.google.protobuf.CodedOutputStream
.computeStringSize(1, getType());
}
- if (hasTo()) {
+ if (hasBoundTo()) {
size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(2, getTo());
+ .computeMessageSize(2, getBoundTo());
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@@ -4434,8 +4520,8 @@
if (other.hasType()) {
setType(other.getType());
}
- if (other.hasTo()) {
- mergeTo(other.getTo());
+ if (other.hasBoundTo()) {
+ mergeBoundTo(other.getBoundTo());
}
this.mergeUnknownFields(other.getUnknownFields());
return this;
@@ -4468,11 +4554,11 @@
}
case 18: {
noop.model.proto.Noop.Expression.Builder subBuilder =
noop.model.proto.Noop.Expression.newBuilder();
- if (hasTo()) {
- subBuilder.mergeFrom(getTo());
+ if (hasBoundTo()) {
+ subBuilder.mergeFrom(getBoundTo());
}
input.readMessage(subBuilder, extensionRegistry);
- setTo(subBuilder.buildPartial());
+ setBoundTo(subBuilder.buildPartial());
break;
}
}
@@ -4501,40 +4587,40 @@
return this;
}

- // required .Expression to = 2;
- public boolean hasTo() {
- return result.hasTo();
- }
- public noop.model.proto.Noop.Expression getTo() {
- return result.getTo();
- }
- public Builder setTo(noop.model.proto.Noop.Expression value) {
+ // required .Expression boundTo = 2;
+ public boolean hasBoundTo() {
+ return result.hasBoundTo();
+ }
+ public noop.model.proto.Noop.Expression getBoundTo() {
+ return result.getBoundTo();
+ }
+ public Builder setBoundTo(noop.model.proto.Noop.Expression value) {
if (value == null) {
throw new NullPointerException();
}
- result.hasTo = true;
- result.to_ = value;
+ result.hasBoundTo = true;
+ result.boundTo_ = value;
return this;
}
- public Builder setTo(noop.model.proto.Noop.Expression.Builder
builderForValue) {
- result.hasTo = true;
- result.to_ = builderForValue.build();
+ public Builder setBoundTo(noop.model.proto.Noop.Expression.Builder
builderForValue) {
+ result.hasBoundTo = true;
+ result.boundTo_ = builderForValue.build();
return this;
}
- public Builder mergeTo(noop.model.proto.Noop.Expression value) {
- if (result.hasTo() &&
- result.to_ !=
noop.model.proto.Noop.Expression.getDefaultInstance()) {
- result.to_ =
-
noop.model.proto.Noop.Expression.newBuilder(result.to_).mergeFrom(value).buildPartial();
+ public Builder mergeBoundTo(noop.model.proto.Noop.Expression value) {
+ if (result.hasBoundTo() &&
+ result.boundTo_ !=
noop.model.proto.Noop.Expression.getDefaultInstance()) {
+ result.boundTo_ =
+
noop.model.proto.Noop.Expression.newBuilder(result.boundTo_).mergeFrom(value).buildPartial();
} else {
- result.to_ = value;
- }
- result.hasTo = true;
+ result.boundTo_ = value;
+ }
+ result.hasBoundTo = true;
return this;
}
- public Builder clearTo() {
- result.hasTo = false;
- result.to_ = noop.model.proto.Noop.Expression.getDefaultInstance();
+ public Builder clearBoundTo() {
+ result.hasBoundTo = false;
+ result.boundTo_ =
noop.model.proto.Noop.Expression.getDefaultInstance();
return this;
}
}
@@ -6784,32 +6870,33 @@
"\n\tInterface\022\014\n\004name\030\001
\002(\t\022\025\n\rdocumentati" +
"on\030\002 \001(\t\022 \n\006method\030\003
\003(\0132\020.MethodSignatu" +
"re\"8\n\005Alias\022\014\n\004name\030\001
\002(\t\022\025\n\rdocumentati" +
- "on\030\002 \001(\t\022\n\n\002of\030\003
\002(\t\"h\n\017MethodSignature\022" +
- "\014\n\004name\030\001 \002(\t\022\025\n\rdocumentation\030\002
\001(\t\022\023\n\013" +
- "return_type\030\003 \003(\t\022\033\n\010argument\030\004
\003(\0132\t.Pr",
- "operty\"D\n\006Method\022#\n\tsignature\030\001 \002(\0132\020.Me" +
- "thodSignature\022\025\n\005block\030\002
\002(\0132\006.Block\"+\n\014" +
- "BindingBlock\022\033\n\004bind\030\001 \003(\0132\r.BindOperato" +
- "r\"5\n\014BindOperator\022\014\n\004type\030\001
\002(\t\022\027\n\002to\030\002 " +
- "\002(\0132\013.Expression\"&\n\005Block\022\035\n\tstatement\030\001"
+
- "
\003(\0132\n.Statement\"\253\001\n\tStatement\022\035\n\004type\030\001" +
- " \002(\0162\017.Statement.Type\022+\n\020methodInvocatio" +
- "n\030\002
\001(\0132\021.MethodInvocation\022\035\n\010returned\030\003" +
- " \001(\0132\013.Expression\"3\n\004Type\022\025\n\021METHOD_INVO" +
- "CATION\020\001\022\024\n\020RETURN_STATEMENT\020\002\"[\n\020Method",
- "Invocation\022\030\n\003lhs\030\001
\002(\0132\013.Expression\022\016\n\006" +
- "method\030\002 \002(\t\022\035\n\010argument\030\003
\003(\0132\013.Express" +
- "ion\"\254\002\n\nExpression\022\036\n\004type\030\001
\002(\0162\020.Expre" +
- "ssion.Type\022\022\n\nbooleanVal\030\002
\001(\010\022\021\n\tstring" +
- "Val\030\003 \001(\t\022\021\n\tnumberVal\030\004
\001(\r\022\030\n\003lhs\030\005 \001(" +
- "\0132\013.Expression\022\030\n\003rhs\030\006
\001(\0132\013.Expression" +
- "\"\217\001\n\004Type\022\r\n\tEVALUATED\020\001\022\023\n\017BOOLEAN_LITE"
+
- "RAL\020\002\022\022\n\016STRING_LITERAL\020\003\022\022\n\016NUMBER_LITE"
+
- "RAL\020\004\022\016\n\nIDENTIFIER\020\005\022\017\n\013CONDITIONAL\020\006\022\017"
+
- "\n\013DEREFERENCE\020\007\022\t\n\005INDEX\020\010\"6\n\010Unittest\022\023",
- "\n\013description\030\001 \002(\t\022\025\n\rdocumentation\030\002
\001" +
- "(\t*\027\n\010Modifier\022\013\n\007MUTABLE\020\001B\022\n\020noop.mode"
+
- "l.proto"
+ "on\030\002 \001(\t\022\n\n\002of\030\003
\002(\t\"\205\001\n\017MethodSignature" +
+ "\022\014\n\004name\030\001 \002(\t\022\025\n\rdocumentation\030\002
\001(\t\022\033\n" +
+ "\010modifier\030\003 \003(\0162\t.Modifier\022\023\n\013return_typ",
+ "e\030\004 \003(\t\022\033\n\010argument\030\005
\003(\0132\t.Property\"D\n\006" +
+ "Method\022#\n\tsignature\030\001 \002(\0132\020.MethodSignat" +
+ "ure\022\025\n\005block\030\002
\002(\0132\006.Block\"+\n\014BindingBlo" +
+ "ck\022\033\n\004bind\030\001
\003(\0132\r.BindOperator\":\n\014BindO" +
+ "perator\022\014\n\004type\030\001
\002(\t\022\034\n\007boundTo\030\002 \002(\0132\013" +
+ ".Expression\"&\n\005Block\022\035\n\tstatement\030\001 \003(\0132" +
+ "\n.Statement\"\253\001\n\tStatement\022\035\n\004type\030\001
\002(\0162" +
+ "\017.Statement.Type\022+\n\020methodInvocation\030\002 \001" +
+ "(\0132\021.MethodInvocation\022\035\n\010returned\030\003
\001(\0132" +
+ "\013.Expression\"3\n\004Type\022\025\n\021METHOD_INVOCATIO",
+ "N\020\001\022\024\n\020RETURN_STATEMENT\020\002\"[\n\020MethodInvoc"
+
+ "ation\022\030\n\003lhs\030\001
\002(\0132\013.Expression\022\016\n\006metho" +
+ "d\030\002 \002(\t\022\035\n\010argument\030\003
\003(\0132\013.Expression\"\254" +
+ "\002\n\nExpression\022\036\n\004type\030\001
\002(\0162\020.Expression" +
+ ".Type\022\022\n\nbooleanVal\030\002
\001(\010\022\021\n\tstringVal\030\003" +
+ " \001(\t\022\021\n\tnumberVal\030\004
\001(\r\022\030\n\003lhs\030\005 \001(\0132\013.E" +
+ "xpression\022\030\n\003rhs\030\006
\001(\0132\013.Expression\"\217\001\n\004" +
+ "Type\022\r\n\tEVALUATED\020\001\022\023\n\017BOOLEAN_LITERAL\020\002"
+
+ "\022\022\n\016STRING_LITERAL\020\003\022\022\n\016NUMBER_LITERAL\020\004"
+
+ "\022\016\n\nIDENTIFIER\020\005\022\017\n\013CONDITIONAL\020\006\022\017\n\013DER",
+ "EFERENCE\020\007\022\t\n\005INDEX\020\010\"6\n\010Unittest\022\023\n\013des"
+
+ "cription\030\001 \002(\t\022\025\n\rdocumentation\030\002
\001(\t*#\n" +
+ "\010Modifier\022\013\n\007MUTABLE\020\001\022\n\n\006NATIVE\020\002B\022\n\020no"
+
+ "op.model.proto"
};

com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner
assigner =
new
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner()
{
@@ -6869,7 +6956,7 @@
internal_static_MethodSignature_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_MethodSignature_descriptor,
- new java.lang.String[]
{ "Name", "Documentation", "ReturnType", "Argument", },
+ new java.lang.String[]
{ "Name", "Documentation", "Modifier", "ReturnType", "Argument", },
noop.model.proto.Noop.MethodSignature.class,
noop.model.proto.Noop.MethodSignature.Builder.class);
internal_static_Method_descriptor =
@@ -6893,7 +6980,7 @@
internal_static_BindOperator_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_BindOperator_descriptor,
- new java.lang.String[] { "Type", "To", },
+ new java.lang.String[] { "Type", "BoundTo", },
noop.model.proto.Noop.BindOperator.class,
noop.model.proto.Noop.BindOperator.Builder.class);
internal_static_Block_descriptor =
=======================================
--- /core/src/main/proto/noop.proto Thu Dec 10 22:05:16 2009
+++ /core/src/main/proto/noop.proto Fri Dec 11 00:03:26 2009
@@ -6,6 +6,7 @@

enum Modifier {
MUTABLE = 1;
+ NATIVE = 2;
}

message Module {
@@ -55,8 +56,9 @@
message MethodSignature {
required string name = 1;
optional string documentation = 2;
- repeated string return_type = 3;
- repeated Property argument = 4;
+ repeated Modifier modifier = 3;
+ repeated string return_type = 4;
+ repeated Property argument = 5;
}

message Method {
=======================================
--- /core/src/main/scala/noop/model/BindingDeclaration.scala Thu Dec 10
22:06:44 2009
+++ /core/src/main/scala/noop/model/BindingDeclaration.scala Fri Dec 11
00:03:26 2009
@@ -23,10 +23,13 @@
*/
class BindingDeclaration(val data: BindOperator) extends Expression {

+ def noopType: String = data.getType;
+ def boundTo: Expression = ExpressionConverter.fromData(data.getBoundTo);
+
def accept(visitor: Visitor) = {
- Expression.forData(data.getTo).accept(visitor);
+ ExpressionConverter.fromData(data.getBoundTo).accept(visitor);
visitor.visit(this);
}

- override def toString() = data.getType + " -> " + data.getTo;
-}
+ override def toString() = data.getType + " -> " + data.getBoundTo;
+}
=======================================
--- /core/src/main/scala/noop/model/Block.scala Sat Nov 7 12:07:39 2009
+++ /core/src/main/scala/noop/model/Block.scala Fri Dec 11 00:03:26 2009
@@ -15,13 +15,14 @@
*/
package noop.model;

-import collection.mutable.{ArrayBuffer, Buffer};
+import collection.mutable.{ArrayBuffer, Buffer}
+import proto.Noop;

/**
* @author alex...@google.com (Alex Eagle)
* @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
*/
-class Block extends Expression {
+class Block(val data: Noop.Block) extends Expression {

val statements: Buffer[Expression] = new ArrayBuffer[Expression]();
val anonymousBindings: Buffer[BindingDeclaration] = new
ArrayBuffer[BindingDeclaration];
=======================================
--- /core/src/main/scala/noop/model/ClassDefinition.scala Thu Dec 10
22:06:44 2009
+++ /core/src/main/scala/noop/model/ClassDefinition.scala Fri Dec 11
00:03:26 2009
@@ -16,9 +16,6 @@
package noop.model;

/**
- * namespace is mutable because we may infer the namespace from the
relative path of the file
- *
* @author alex...@google.com (Alex Eagle)
- * @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
*/
trait ClassDefinition
=======================================
--- /core/src/main/scala/noop/model/ConcreteClassDefinition.scala Thu Dec
10 22:06:44 2009
+++ /core/src/main/scala/noop/model/ConcreteClassDefinition.scala Fri Dec
11 00:03:26 2009
@@ -15,8 +15,8 @@
*/
package noop.model

-import proto.Noop.{Method, ConcreteClass}
import collection.jcl.Buffer
+import proto.Noop.{Unittest, Property, Method, ConcreteClass}

/**
* An AST element representing a concrete class. To the user, this is
a "class", but to us,
@@ -27,6 +27,10 @@
*/

class ConcreteClassDefinition(val data: ConcreteClass) extends
ClassDefinition {
+ def properties: Seq[Property] = Buffer(data.getPropertyList);
+ def name: String = data.getName;
+ def unittests: Seq[Unittest] = Buffer(data.getUnittestList);
+
def findMethod(methodName: String): MethodDefinition = {
val methods: Seq[Method] = Buffer(data.getMethodList());
methods.find((method: Method) => method.getSignature.getName ==
methodName) match {
=======================================
--- /core/src/main/scala/noop/model/ExpressionConverter.scala Thu Dec 10
22:06:44 2009
+++ /core/src/main/scala/noop/model/ExpressionConverter.scala Fri Dec 11
00:03:26 2009
@@ -7,7 +7,13 @@
* @author alex...@google.com (Alex Eagle)
*/
object ExpressionConverter {
- def fromData(expr: Noop.Expression): Expression = {
-
+ def fromData(expr: Noop.Expression): Expression = expr.getType match {
+ case Noop.Expression.Type.IDENTIFIER => new
IdentifierExpression(expr.getStringVal);
+ case Noop.Expression.Type.STRING_LITERAL => new
StringLiteralExpression(expr.getStringVal);
+ case Noop.Expression.Type.NUMBER_LITERAL => new
IntLiteralExpression(expr.getNumberVal);
+ case Noop.Expression.Type.BOOLEAN_LITERAL => new
BooleanLiteralExpression(expr.getBooleanVal);
+ case Noop.Expression.Type.DEREFERENCE => new
DereferenceExpression(fromData(expr.getLhs), fromData(expr.getRhs));
+ case Noop.Expression.Type.CONDITIONAL => new
ConditionalAndExpression(fromData(expr.getLhs), fromData(expr.getRhs));
+ case _ => throw new IllegalArgumentException("Cannot convert proto
expression with type " + expr.getType);
}
}
=======================================
--- /core/src/main/scala/noop/model/LoggingAstVisitor.scala Thu Dec 10
22:06:44 2009
+++ /core/src/main/scala/noop/model/LoggingAstVisitor.scala Fri Dec 11
00:03:26 2009
@@ -59,7 +59,7 @@
}

def visit(method: MethodDefinition) = {
- logger.info("Method: " + method.data.getSignature.getName);
+ logger.info("Method: " + method.name);
}

def enter(methodInvocationExpression: MethodInvocationExpression) = {
=======================================
--- /core/src/main/scala/noop/model/MethodDefinition.scala Thu Dec 10
22:06:44 2009
+++ /core/src/main/scala/noop/model/MethodDefinition.scala Fri Dec 11
00:03:26 2009
@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package noop.model;
-
-import proto.Noop.Method;
+package noop.model
+
+import collection.jcl.Buffer
+import proto.Noop.{Modifier, Property, Method};

/**
* Represents the declaration of a method in source code.
@@ -24,6 +25,11 @@
* @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
*/
class MethodDefinition(val data: Method) {
+ def name:String = data.getSignature.getName;
+ def parameters: Seq[Property] =
Buffer(data.getSignature.getArgumentList);
+ def modifiers: Seq[Modifier] = Buffer(data.getSignature.getModifierList);
+ def block: Block = new Block(data.getBlock);
+
override def toString() = String.format("Method %s (%s) returns %s",
data.getSignature.getName, data.getSignature.getArgumentList,
data.getSignature.getReturnTypeList);
}
=======================================
--- /core/src/main/scala/noop/model/Module.scala Thu Dec 10 22:06:44 2009
+++ /core/src/main/scala/noop/model/Module.scala Fri Dec 11 00:03:26 2009
@@ -1,8 +1,9 @@
package noop.model

-import collection.mutable.{ArrayBuffer, Buffer}
+import collection.mutable.{Buffer, ArrayBuffer}

/**
+ * A module is a collection of classes. It might be useful to have it
correspond with a subproject/module/component
* @author alex...@google.com (Alex Eagle)
*/

=======================================
--- /core/src/main/scala/noop/types/NoopObject.scala Thu Dec 10 22:06:44
2009
+++ /core/src/main/scala/noop/types/NoopObject.scala Fri Dec 11 00:03:26
2009
@@ -15,8 +15,7 @@
*/
package noop.types;

-import collection.mutable.Map;
-
+import collection.mutable.Map
import noop.model.ClassDefinition;

/**
=======================================
--- /core/src/test/java/noop/model/proto/ProtoBufferSpike.java Thu Dec 10
22:05:16 2009
+++ /core/src/test/java/noop/model/proto/ProtoBufferSpike.java Fri Dec 11
00:03:26 2009
@@ -26,7 +26,7 @@
.setBlock(BindingBlock.newBuilder()
.addBind(BindOperator.newBuilder()
.setType("noop.Application")
- .setTo(Expression.newBuilder().setType(IDENTIFIER).setStringVal("example.CmdLineArgs")))))
+ .setBoundTo(Expression.newBuilder().setType(IDENTIFIER).setStringVal("example.CmdLineArgs")))))
.addConcreteClass(ConcreteClass.newBuilder()
.setName("example.CmdLineArgs")
.setDocumentation("Demonstrates reading command line arguments
in Noop.")
=======================================
--- /interpreter/src/main/scala/noop/inject/GuiceBackedInjector.scala Thu
Dec 10 22:06:44 2009
+++ /interpreter/src/main/scala/noop/inject/GuiceBackedInjector.scala Fri
Dec 11 00:03:26 2009
@@ -35,14 +35,14 @@
var currentInjector: com.google.inject.Injector = injector;

def getInstance(classDef: ConcreteClassDefinition): NoopObject = {
- val obj = classDef.data.getName match {
+ val obj = classDef.name match {
case "noop.Console" => new
NoopConsole(classLoader.findClass("noop.Console"));
case _ => new NoopObject(classDef);
}

- for (property: Property <- Buffer(classDef.data.getPropertyList())) {
+ for (property: Property <- classDef.properties) {
val propClassDef = classLoader.findClass(property.getType);
- obj.propertyMap += Pair(property.getName,
getInstance(paramClassDef));
+ obj.propertyMap += Pair(property.getName,
getInstance(propClassDef.asInstanceOf[ConcreteClassDefinition]));
}
return obj;
}
=======================================
--- /interpreter/src/main/scala/noop/interpreter/ClassLoader.scala Thu Oct
8 10:25:57 2009
+++ /interpreter/src/main/scala/noop/interpreter/ClassLoader.scala Fri Dec
11 00:03:26 2009
@@ -15,9 +15,8 @@
*/
package noop.interpreter;

-import java.io.File;
-
-import model.ClassDefinition;
+import java.io.File
+import noop.model.ClassDefinition;

/**
* @author alex...@google.com (Alex Eagle)
=======================================
--- /interpreter/src/main/scala/noop/interpreter/ClassSearch.scala Thu Oct
8 10:25:57 2009
+++ /interpreter/src/main/scala/noop/interpreter/ClassSearch.scala Fri Dec
11 00:03:26 2009
@@ -15,12 +15,12 @@
*/
package noop.interpreter;

-import model.ClassDefinition;
+import noop.model.ConcreteClassDefinition;

/**
* @author alex...@google.com (Alex Eagle)
*/
trait ClassSearch {

- def eachClass(f: ClassDefinition => Unit);
-}
+ def eachClass(f: ConcreteClassDefinition => Unit);
+}
=======================================
--- /interpreter/src/main/scala/noop/interpreter/Interpreter.scala Thu Dec
3 21:26:31 2009
+++ /interpreter/src/main/scala/noop/interpreter/Interpreter.scala Fri Dec
11 00:03:26 2009
@@ -34,7 +34,7 @@
bindingDefinition.bindings.find((b: BindingDeclaration) => b.noopType
== "Application") match {
case Some(binding: BindingDeclaration) => {
val applicationType =
binding.boundTo.asInstanceOf[IdentifierExpression].identifier;
- val applicationClass =
classLoader.findClass(bindingDefinition.resolveType(applicationType));
+ val applicationClass = classLoader.findClass(applicationType);
applicationClass match {
case concrete: ConcreteClassDefinition =>
runFromConcrete(concrete);
case _ => throw new IllegalStateException("Application must be
bound to concrete class");
=======================================
--- /interpreter/src/main/scala/noop/interpreter/InterpreterVisitor.scala
Thu Dec 3 18:36:36 2009
+++ /interpreter/src/main/scala/noop/interpreter/InterpreterVisitor.scala
Fri Dec 11 00:03:26 2009
@@ -15,20 +15,16 @@
*/
package noop.interpreter;

-import com.google.inject.Inject;
-import inject.Injector;
+import com.google.inject.Inject
+import noop.model.proto.Noop;
+import noop.inject.Injector;
import org.slf4j.LoggerFactory;

import scala.collection.mutable.ArrayBuffer;

-import interpreter.testing.TestFailedException;
-import model.{AssignmentExpression, BindingDeclaration, Block,
BooleanLiteralExpression,
- ConditionalAndExpression, ConditionalOrExpression,
DereferenceExpression,
- EvaluatedExpression, IdentifierDeclarationExpression,
IdentifierExpression,
- IntLiteralExpression, Method, MethodInvocationExpression, Modifier,
- OperatorExpression, ReturnExpression, ShouldExpression,
StringLiteralExpression,
- Visitor, WhileLoop};
-import types._;
+import noop.interpreter.testing.TestFailedException;
+import noop.model._;
+import noop.types._;

/**
* @author alex...@google.com (Alex Eagle)
@@ -129,12 +125,12 @@
evaluationStackSize = -1;
}

- def visit(method: Method) = {
- if (method.modifiers.contains(Modifier.native)) {
+ def visit(method: MethodDefinition) = {
+ if (method.modifiers.contains(Noop.Modifier.NATIVE)) {
val obj = context.stack.top.thisRef;
val arguments = new ArrayBuffer[NoopObject];
for (parameter <- method.parameters) {
- arguments +=
context.stack.top.blockScopes.getIdentifier(parameter.name)._2;
+ arguments +=
context.stack.top.blockScopes.getIdentifier(parameter.getName)._2;
}
val returnValue = obj.executeNativeMethod(arguments, method.name);
context.stack.top.lastEvaluated += returnValue;
=======================================
---
/interpreter/src/main/scala/noop/interpreter/MethodInvocationEvaluator.scala
Tue Nov 17 20:40:59 2009
+++
/interpreter/src/main/scala/noop/interpreter/MethodInvocationEvaluator.scala
Fri Dec 11 00:03:26 2009
@@ -15,11 +15,12 @@
*/
package noop.interpreter;

-import collection.mutable.Stack;
+import collection.mutable.Stack
+import noop.model.{ConcreteClassDefinition, MethodInvocationExpression,
Visitor};
import org.slf4j.LoggerFactory;

-import model.{MethodInvocationExpression, Visitor};
-import types.{NoopObject, NoopType};
+
+import noop.types.{NoopObject, NoopType};

/**
* @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
@@ -29,7 +30,7 @@
val logger = LoggerFactory.getLogger(this.getClass);

def createFrame(context: Context, thisRef: NoopObject): Frame = {
- val method =
thisRef.classDef.findMethod(methodInvocationExpression.name);
+ val method =
thisRef.classDef.asInstanceOf[ConcreteClassDefinition].findMethod(methodInvocationExpression.name);

return new Frame(thisRef, method);
}
@@ -56,7 +57,7 @@
context.stack.top.blockScopes.inScope("method " + method) {
for (i <- 0 until method.parameters.size) {
val value = arguments.pop();
- val identifier = method.parameters(i).name;
+ val identifier = method.parameters(i).getName;

frame.addIdentifier(identifier, new Tuple2[NoopType,
NoopObject](null, value));
}
=======================================
---
/interpreter/src/main/scala/noop/interpreter/SourceFileClassLoader.scala
Thu Dec 10 22:06:44 2009
+++
/interpreter/src/main/scala/noop/interpreter/SourceFileClassLoader.scala
Fri Dec 11 00:03:26 2009
@@ -50,27 +50,12 @@
val expectedFile = parts.last + ".noop";
val relativePath = parts.take(parts.size - 1).mkString(File.separator);

- val classDef: ConcreteClassDefinition =
searchInClasspath(relativePath, expectedFile) match {
- case Some(c) => c;
+ searchInClasspath(relativePath, expectedFile) match {
case None => searchInFilesystem(relativePath, expectedFile) match {
case Some(c) => c;
case None => throw new ClassNotFoundException("Could not find
class: " + className);
}
}
-
- return postProcess(classDef, className);
- }
-
- /**
- * We want the AST produced by the ANTLR tree parser to be free from
interpreter specific stuff.
- * But, the AST is in a raw form, so we fill in some details to make
interpreting easier.
- */
- def postProcess(classDef: ClassDefinition, className: String):
ClassDefinition = {
- if (classDef.namespace == "") {
- val parts = className.split("\\.");
- classDef.namespace = parts.take(parts.size - 1).mkString(".");
- }
- return classDef;
}

def searchInClasspath(relativePath: String, expectedFile: String):
Option[ConcreteClassDefinition] = {
@@ -117,8 +102,7 @@
eachClassInPath(file, newRelativePath, f);
} else if (file.getName().endsWith(".noop")) {
val classDef = getClassDefinition(file)
- val className = relativePath + file.getName().substring(0,
file.getName().length - 5);
- f.apply(postProcess(classDef, className));
+ f.apply(classDef);
}
}
}
=======================================
--- /interpreter/src/main/scala/noop/interpreter/testing/TestHolder.scala
Thu Oct 8 10:25:57 2009
+++ /interpreter/src/main/scala/noop/interpreter/testing/TestHolder.scala
Fri Dec 11 00:03:26 2009
@@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package noop.interpreter.testing;
-
-import model.{ClassDefinition, Method};
+package noop.interpreter.testing
+
+import noop.model.{UnittestDefinition, ConcreteClassDefinition}
+

/**
* @author alex...@google.com (Alex Eagle)
*/
-class TestHolder(val classDef: ClassDefinition, val testMethod: Method)
+class TestHolder(val classDef: ConcreteClassDefinition, val testMethod:
UnittestDefinition)
=======================================
--- /interpreter/src/main/scala/noop/interpreter/testing/TestRunner.scala
Tue Nov 17 18:47:39 2009
+++ /interpreter/src/main/scala/noop/interpreter/testing/TestRunner.scala
Fri Dec 11 00:03:26 2009
@@ -17,10 +17,10 @@

import collection.mutable.{ArrayBuffer, Buffer, Stack}
import com.google.inject.{Inject, Guice}
-import inject.{Injector}
-
-import model._
-import types.{NoopBoolean, BooleanFactory}
+import noop.inject.{Injector}
+
+import noop.model._
+import noop.types.{NoopBoolean, BooleanFactory}
/**
* @author alex...@google.com (Alex Eagle)
*/
@@ -29,9 +29,9 @@

def gatherTests(): Buffer[TestHolder] = {
var tests = new ArrayBuffer[TestHolder];
- classSearch.eachClass((c:ClassDefinition) => {
+ classSearch.eachClass((c:ConcreteClassDefinition) => {
for (testMethod <- c.unittests) {
- tests += new TestHolder(c, testMethod);
+ tests += new TestHolder(c, new UnittestDefinition(testMethod));
}
});
return tests;
Reply all
Reply to author
Forward
0 new messages