[noop] 2 new revisions pushed by aeagle22206 on 2009-12-15 07:02 GMT

1 view
Skip to first unread message

no...@googlecode.com

unread,
Dec 15, 2009, 2:03:07 AM12/15/09
to noop-c...@googlegroups.com
2 new revisions:

Revision: 4659421b63
Author: Alex Eagle <aeagl...@gmail.com>
Date: Mon Dec 14 22:38:11 2009
Log: Update the model objects to be wrappers around protos. They hold the
p...
http://code.google.com/p/noop/source/detail?r=4659421b63

Revision: 3757d8234f
Author: Alex Eagle <aeagl...@gmail.com>
Date: Mon Dec 14 22:46:07 2009
Log: Replace the noop stdlib in source files with the corresponding pure
AS...
http://code.google.com/p/noop/source/detail?r=3757d8234f

==============================================================================
Revision: 4659421b63
Author: Alex Eagle <aeagl...@gmail.com>
Date: Mon Dec 14 22:38:11 2009
Log: Update the model objects to be wrappers around protos. They hold the
proto as a private field, and provide accessors which return wrapped
objects. No longer have a SourceFile, for now. Also change the AST so that
a block is a list of expressions. The distinction between statement and
expression is only strong when "if-else" and "while" and so forth have no
value.

I'm hoping to merge this branch to trunk before long. This means the
grammar will stay broken for a while, but I hope it's justified by being
able to make more serious changes in the near future without having to
refactor the ANTLR grammar and update source-code-based examples to cope
with grammar changes. We can revisit syntax later on when the AST and
execution model are more complete.
http://code.google.com/p/noop/source/detail?r=4659421b63

Added:
/core/src/main/scala/noop/model/Invokable.scala
/core/src/main/scala/noop/model/ModuleDefinition.scala
Deleted:
/core/src/main/scala/noop/model/AstRoot.scala
/core/src/main/scala/noop/model/Module.scala
/core/src/main/scala/noop/model/SourceFile.scala
Modified:
/core/src/main/java/noop/model/proto/Noop.java
/core/src/main/proto/noop.proto
/core/src/main/scala/noop/model/AliasDefinition.scala
/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/InterfaceDefinition.scala
/core/src/main/scala/noop/model/MethodDefinition.scala
/core/src/main/scala/noop/model/UnittestDefinition.scala
/core/src/main/scala/noop/model/Visitor.scala
/core/src/main/scala/noop/model/persistence/ClassRepository.scala
/core/src/test/java/noop/model/proto/ProtoBufferSpike.java

=======================================
--- /dev/null
+++ /core/src/main/scala/noop/model/Invokable.scala Mon Dec 14 22:38:11 2009
@@ -0,0 +1,27 @@
+/*
+ * 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
+
+import proto.Noop.Property
+
+/**
+ * @author alex...@google.com (Alex Eagle)
+ */
+
+trait Invokable {
+ def name: String;
+ def parameters: Seq[Property];
+}
=======================================
--- /dev/null
+++ /core/src/main/scala/noop/model/ModuleDefinition.scala Mon Dec 14
22:38:11 2009
@@ -0,0 +1,19 @@
+package noop.model
+
+import collection.mutable.{Buffer, ArrayBuffer}
+import collection.jcl.Buffer
+import proto.Noop.{ConcreteClass, Module}
+
+/**
+ * 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)
+ */
+
+class ModuleDefinition(data: Module) {
+ def findClass(name: String) = {
+ Buffer(data.getConcreteClassList).find((c: ConcreteClass) => c.getName
== name) match {
+ case Some(c) => new ConcreteClassDefinition(c);
+ case None => throw new IllegalStateException("Class " + name + " not
found in module " + data.getName);
+ }
+ }
+}
=======================================
--- /core/src/main/scala/noop/model/AstRoot.scala Thu Dec 10 22:06:44 2009
+++ /dev/null
@@ -1,11 +0,0 @@
-package noop.model
-
-import collection.mutable.{ArrayBuffer, Buffer}
-
-/**
- * @author alex...@google.com (Alex Eagle)
- */
-
-class AstRoot {
- val modules: Buffer[Module] = new ArrayBuffer[Module];
-}
=======================================
--- /core/src/main/scala/noop/model/Module.scala Fri Dec 11 00:03:26 2009
+++ /dev/null
@@ -1,15 +0,0 @@
-package noop.model
-
-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)
- */
-
-class Module(val name: String, val documentation: String) {
- val concreteClasses: Buffer[ConcreteClassDefinition] = new
ArrayBuffer[ConcreteClassDefinition];
- val aliases: Buffer[AliasDefinition] = new ArrayBuffer[AliasDefinition];
- val bindings: Buffer[BindingDefinition] = new
ArrayBuffer[BindingDefinition];
- val interfaces: Buffer[InterfaceDefinition] = new
ArrayBuffer[InterfaceDefinition];
-}
=======================================
--- /core/src/main/scala/noop/model/SourceFile.scala Fri Nov 13 17:38:34
2009
+++ /dev/null
@@ -1,30 +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;
-
-import scala.collection.mutable.{ArrayBuffer, Buffer};
-
-/**
- * A Noop source file.
- *
- * @author alex...@google.com (Alex Eagle)
- */
-class SourceFile {
-
- var namespace: String = "";
- var imports: Buffer[String] = new ArrayBuffer[String];
- var classDef: ClassDefinition = null;
-}
=======================================
--- /core/src/main/java/noop/model/proto/Noop.java Fri Dec 11 00:03:26 2009
+++ /core/src/main/java/noop/model/proto/Noop.java Mon Dec 14 22:38:11 2009
@@ -4658,20 +4658,20 @@
return
noop.model.proto.Noop.internal_static_Block_fieldAccessorTable;
}

- // repeated .Statement statement = 1;
- public static final int STATEMENT_FIELD_NUMBER = 1;
- private java.util.List<noop.model.proto.Noop.Statement> statement_ =
+ // repeated .Expression expression = 1;
+ public static final int EXPRESSION_FIELD_NUMBER = 1;
+ private java.util.List<noop.model.proto.Noop.Expression> expression_ =
java.util.Collections.emptyList();
- public java.util.List<noop.model.proto.Noop.Statement>
getStatementList() {
- return statement_;
- }
- public int getStatementCount() { return statement_.size(); }
- public noop.model.proto.Noop.Statement getStatement(int index) {
- return statement_.get(index);
+ public java.util.List<noop.model.proto.Noop.Expression>
getExpressionList() {
+ return expression_;
+ }
+ public int getExpressionCount() { return expression_.size(); }
+ public noop.model.proto.Noop.Expression getExpression(int index) {
+ return expression_.get(index);
}

public final boolean isInitialized() {
- for (noop.model.proto.Noop.Statement element : getStatementList()) {
+ for (noop.model.proto.Noop.Expression element : getExpressionList())
{
if (!element.isInitialized()) return false;
}
return true;
@@ -4679,7 +4679,7 @@

public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
- for (noop.model.proto.Noop.Statement element : getStatementList()) {
+ for (noop.model.proto.Noop.Expression element : getExpressionList())
{
output.writeMessage(1, element);
}
getUnknownFields().writeTo(output);
@@ -4691,7 +4691,7 @@
if (size != -1) return size;

size = 0;
- for (noop.model.proto.Noop.Statement element : getStatementList()) {
+ for (noop.model.proto.Noop.Expression element : getExpressionList())
{
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(1, element);
}
@@ -4828,9 +4828,9 @@
throw new IllegalStateException(
"build() has already been called on this Builder.");
}
- if (result.statement_ != java.util.Collections.EMPTY_LIST) {
- result.statement_ =
- java.util.Collections.unmodifiableList(result.statement_);
+ if (result.expression_ != java.util.Collections.EMPTY_LIST) {
+ result.expression_ =
+ java.util.Collections.unmodifiableList(result.expression_);
}
noop.model.proto.Noop.Block returnMe = result;
result = null;
@@ -4848,11 +4848,11 @@

public Builder mergeFrom(noop.model.proto.Noop.Block other) {
if (other == noop.model.proto.Noop.Block.getDefaultInstance())
return this;
- if (!other.statement_.isEmpty()) {
- if (result.statement_.isEmpty()) {
- result.statement_ = new
java.util.ArrayList<noop.model.proto.Noop.Statement>();
- }
- result.statement_.addAll(other.statement_);
+ if (!other.expression_.isEmpty()) {
+ if (result.expression_.isEmpty()) {
+ result.expression_ = new
java.util.ArrayList<noop.model.proto.Noop.Expression>();
+ }
+ result.expression_.addAll(other.expression_);
}
this.mergeUnknownFields(other.getUnknownFields());
return this;
@@ -4880,9 +4880,9 @@
break;
}
case 10: {
- noop.model.proto.Noop.Statement.Builder subBuilder =
noop.model.proto.Noop.Statement.newBuilder();
+ noop.model.proto.Noop.Expression.Builder subBuilder =
noop.model.proto.Noop.Expression.newBuilder();
input.readMessage(subBuilder, extensionRegistry);
- addStatement(subBuilder.buildPartial());
+ addExpression(subBuilder.buildPartial());
break;
}
}
@@ -4890,531 +4890,57 @@
}


- // repeated .Statement statement = 1;
- public java.util.List<noop.model.proto.Noop.Statement>
getStatementList() {
- return java.util.Collections.unmodifiableList(result.statement_);
- }
- public int getStatementCount() {
- return result.getStatementCount();
- }
- public noop.model.proto.Noop.Statement getStatement(int index) {
- return result.getStatement(index);
- }
- public Builder setStatement(int index,
noop.model.proto.Noop.Statement value) {
+ // repeated .Expression expression = 1;
+ public java.util.List<noop.model.proto.Noop.Expression>
getExpressionList() {
+ return java.util.Collections.unmodifiableList(result.expression_);
+ }
+ public int getExpressionCount() {
+ return result.getExpressionCount();
+ }
+ public noop.model.proto.Noop.Expression getExpression(int index) {
+ return result.getExpression(index);
+ }
+ public Builder setExpression(int index,
noop.model.proto.Noop.Expression value) {
if (value == null) {
throw new NullPointerException();
}
- result.statement_.set(index, value);
+ result.expression_.set(index, value);
return this;
}
- public Builder setStatement(int index,
noop.model.proto.Noop.Statement.Builder builderForValue) {
- result.statement_.set(index, builderForValue.build());
+ public Builder setExpression(int index,
noop.model.proto.Noop.Expression.Builder builderForValue) {
+ result.expression_.set(index, builderForValue.build());
return this;
}
- public Builder addStatement(noop.model.proto.Noop.Statement value) {
+ public Builder addExpression(noop.model.proto.Noop.Expression value)
{
if (value == null) {
throw new NullPointerException();
}
- if (result.statement_.isEmpty()) {
- result.statement_ = new
java.util.ArrayList<noop.model.proto.Noop.Statement>();
- }
- result.statement_.add(value);
+ if (result.expression_.isEmpty()) {
+ result.expression_ = new
java.util.ArrayList<noop.model.proto.Noop.Expression>();
+ }
+ result.expression_.add(value);
return this;
}
- public Builder addStatement(noop.model.proto.Noop.Statement.Builder
builderForValue) {
- if (result.statement_.isEmpty()) {
- result.statement_ = new
java.util.ArrayList<noop.model.proto.Noop.Statement>();
- }
- result.statement_.add(builderForValue.build());
+ public Builder
addExpression(noop.model.proto.Noop.Expression.Builder builderForValue) {
+ if (result.expression_.isEmpty()) {
+ result.expression_ = new
java.util.ArrayList<noop.model.proto.Noop.Expression>();
+ }
+ result.expression_.add(builderForValue.build());
return this;
}
- public Builder addAllStatement(
- java.lang.Iterable<? extends noop.model.proto.Noop.Statement>
values) {
- if (result.statement_.isEmpty()) {
- result.statement_ = new
java.util.ArrayList<noop.model.proto.Noop.Statement>();
- }
- super.addAll(values, result.statement_);
+ public Builder addAllExpression(
+ java.lang.Iterable<? extends noop.model.proto.Noop.Expression>
values) {
+ if (result.expression_.isEmpty()) {
+ result.expression_ = new
java.util.ArrayList<noop.model.proto.Noop.Expression>();
+ }
+ super.addAll(values, result.expression_);
return this;
}
- public Builder clearStatement() {
- result.statement_ = java.util.Collections.emptyList();
+ public Builder clearExpression() {
+ result.expression_ = java.util.Collections.emptyList();
return this;
}
}
-
- static {
- noop.model.proto.Noop.getDescriptor();
- }
-
- static {
- noop.model.proto.Noop.internalForceInit();
- }
- }
-
- public static final class Statement extends
- com.google.protobuf.GeneratedMessage {
- // Use Statement.newBuilder() to construct.
- private Statement() {}
-
- private static final Statement defaultInstance = new Statement();
- public static Statement getDefaultInstance() {
- return defaultInstance;
- }
-
- public Statement getDefaultInstanceForType() {
- return defaultInstance;
- }
-
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return noop.model.proto.Noop.internal_static_Statement_descriptor;
- }
-
- protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internalGetFieldAccessorTable() {
- return
noop.model.proto.Noop.internal_static_Statement_fieldAccessorTable;
- }
-
- public enum Type
- implements com.google.protobuf.ProtocolMessageEnum {
- METHOD_INVOCATION(0, 1),
- RETURN_STATEMENT(1, 2),
- ;
-
-
- public final int getNumber() { return value; }
-
- public static Type valueOf(int value) {
- switch (value) {
- case 1: return METHOD_INVOCATION;
- case 2: return RETURN_STATEMENT;
- default: return null;
- }
- }
-
- public static com.google.protobuf.Internal.EnumLiteMap<Type>
- internalGetValueMap() {
- return internalValueMap;
- }
- private static com.google.protobuf.Internal.EnumLiteMap<Type>
- internalValueMap =
- new com.google.protobuf.Internal.EnumLiteMap<Type>() {
- public Type findValueByNumber(int number) {
- return Type.valueOf(number)
- ; }
- };
-
- public final com.google.protobuf.Descriptors.EnumValueDescriptor
- getValueDescriptor() {
- return getDescriptor().getValues().get(index);
- }
- public final com.google.protobuf.Descriptors.EnumDescriptor
- getDescriptorForType() {
- return getDescriptor();
- }
- public static final com.google.protobuf.Descriptors.EnumDescriptor
- getDescriptor() {
- return
noop.model.proto.Noop.Statement.getDescriptor().getEnumTypes().get(0);
- }
-
- private static final Type[] VALUES = {
- METHOD_INVOCATION, RETURN_STATEMENT,
- };
- public static Type valueOf(
- com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
- if (desc.getType() != getDescriptor()) {
- throw new java.lang.IllegalArgumentException(
- "EnumValueDescriptor is not for this type.");
- }
- return VALUES[desc.getIndex()];
- }
- private final int index;
- private final int value;
- private Type(int index, int value) {
- this.index = index;
- this.value = value;
- }
-
- static {
- noop.model.proto.Noop.getDescriptor();
- }
- }
-
- // required .Statement.Type type = 1;
- public static final int TYPE_FIELD_NUMBER = 1;
- private boolean hasType;
- private noop.model.proto.Noop.Statement.Type type_ =
noop.model.proto.Noop.Statement.Type.METHOD_INVOCATION;
- public boolean hasType() { return hasType; }
- public noop.model.proto.Noop.Statement.Type getType() { return type_; }
-
- // optional .MethodInvocation methodInvocation = 2;
- public static final int METHODINVOCATION_FIELD_NUMBER = 2;
- private boolean hasMethodInvocation;
- private noop.model.proto.Noop.MethodInvocation methodInvocation_ =
noop.model.proto.Noop.MethodInvocation.getDefaultInstance();
- public boolean hasMethodInvocation() { return hasMethodInvocation; }
- public noop.model.proto.Noop.MethodInvocation getMethodInvocation() {
return methodInvocation_; }
-
- // optional .Expression returned = 3;
- public static final int RETURNED_FIELD_NUMBER = 3;
- private boolean hasReturned;
- private noop.model.proto.Noop.Expression returned_ =
noop.model.proto.Noop.Expression.getDefaultInstance();
- public boolean hasReturned() { return hasReturned; }
- public noop.model.proto.Noop.Expression getReturned() { return
returned_; }
-
- public final boolean isInitialized() {
- if (!hasType) return false;
- if (hasMethodInvocation()) {
- if (!getMethodInvocation().isInitialized()) return false;
- }
- if (hasReturned()) {
- if (!getReturned().isInitialized()) return false;
- }
- return true;
- }
-
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- if (hasType()) {
- output.writeEnum(1, getType().getNumber());
- }
- if (hasMethodInvocation()) {
- output.writeMessage(2, getMethodInvocation());
- }
- if (hasReturned()) {
- output.writeMessage(3, getReturned());
- }
- getUnknownFields().writeTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public int getSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasType()) {
- size += com.google.protobuf.CodedOutputStream
- .computeEnumSize(1, getType().getNumber());
- }
- if (hasMethodInvocation()) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(2, getMethodInvocation());
- }
- if (hasReturned()) {
- size += com.google.protobuf.CodedOutputStream
- .computeMessageSize(3, getReturned());
- }
- size += getUnknownFields().getSerializedSize();
- memoizedSerializedSize = size;
- return size;
- }
-
- public static noop.model.proto.Noop.Statement parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return newBuilder().mergeFrom(data).buildParsed();
- }
- public static noop.model.proto.Noop.Statement parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return newBuilder().mergeFrom(data, extensionRegistry)
- .buildParsed();
- }
- public static noop.model.proto.Noop.Statement parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return newBuilder().mergeFrom(data).buildParsed();
- }
- public static noop.model.proto.Noop.Statement parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return newBuilder().mergeFrom(data, extensionRegistry)
- .buildParsed();
- }
- public static noop.model.proto.Noop.Statement
parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return newBuilder().mergeFrom(input).buildParsed();
- }
- public static noop.model.proto.Noop.Statement parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return newBuilder().mergeFrom(input, extensionRegistry)
- .buildParsed();
- }
- public static noop.model.proto.Noop.Statement
parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return newBuilder().mergeDelimitedFrom(input).buildParsed();
- }
- public static noop.model.proto.Noop.Statement parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return newBuilder().mergeDelimitedFrom(input, extensionRegistry)
- .buildParsed();
- }
- public static noop.model.proto.Noop.Statement parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return newBuilder().mergeFrom(input).buildParsed();
- }
- public static noop.model.proto.Noop.Statement parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return newBuilder().mergeFrom(input, extensionRegistry)
- .buildParsed();
- }
-
- public static Builder newBuilder() { return Builder.create(); }
- public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(noop.model.proto.Noop.Statement
prototype) {
- return newBuilder().mergeFrom(prototype);
- }
- public Builder toBuilder() { return newBuilder(this); }
-
- public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> {
- private noop.model.proto.Noop.Statement result;
-
- // Construct using noop.model.proto.Noop.Statement.newBuilder()
- private Builder() {}
-
- private static Builder create() {
- Builder builder = new Builder();
- builder.result = new noop.model.proto.Noop.Statement();
- return builder;
- }
-
- protected noop.model.proto.Noop.Statement internalGetResult() {
- return result;
- }
-
- public Builder clear() {
- if (result == null) {
- throw new IllegalStateException(
- "Cannot call clear() after build().");
- }
- result = new noop.model.proto.Noop.Statement();
- return this;
- }
-
- public Builder clone() {
- return create().mergeFrom(result);
- }
-
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return noop.model.proto.Noop.Statement.getDescriptor();
- }
-
- public noop.model.proto.Noop.Statement getDefaultInstanceForType() {
- return noop.model.proto.Noop.Statement.getDefaultInstance();
- }
-
- public boolean isInitialized() {
- return result.isInitialized();
- }
- public noop.model.proto.Noop.Statement build() {
- if (result != null && !isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return buildPartial();
- }
-
- private noop.model.proto.Noop.Statement buildParsed()
- throws com.google.protobuf.InvalidProtocolBufferException {
- if (!isInitialized()) {
- throw newUninitializedMessageException(
- result).asInvalidProtocolBufferException();
- }
- return buildPartial();
- }
-
- public noop.model.proto.Noop.Statement buildPartial() {
- if (result == null) {
- throw new IllegalStateException(
- "build() has already been called on this Builder.");
- }
- noop.model.proto.Noop.Statement returnMe = result;
- result = null;
- return returnMe;
- }
-
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof noop.model.proto.Noop.Statement) {
- return mergeFrom((noop.model.proto.Noop.Statement)other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(noop.model.proto.Noop.Statement other) {
- if (other == noop.model.proto.Noop.Statement.getDefaultInstance())
return this;
- if (other.hasType()) {
- setType(other.getType());
- }
- if (other.hasMethodInvocation()) {
- mergeMethodInvocation(other.getMethodInvocation());
- }
- if (other.hasReturned()) {
- mergeReturned(other.getReturned());
- }
- this.mergeUnknownFields(other.getUnknownFields());
- return this;
- }
-
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder(
- this.getUnknownFields());
- while (true) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- this.setUnknownFields(unknownFields.build());
- return this;
- default: {
- if (!parseUnknownField(input, unknownFields,
- extensionRegistry, tag)) {
- this.setUnknownFields(unknownFields.build());
- return this;
- }
- break;
- }
- case 8: {
- int rawValue = input.readEnum();
- noop.model.proto.Noop.Statement.Type value =
noop.model.proto.Noop.Statement.Type.valueOf(rawValue);
- if (value == null) {
- unknownFields.mergeVarintField(1, rawValue);
- } else {
- setType(value);
- }
- break;
- }
- case 18: {
- noop.model.proto.Noop.MethodInvocation.Builder subBuilder =
noop.model.proto.Noop.MethodInvocation.newBuilder();
- if (hasMethodInvocation()) {
- subBuilder.mergeFrom(getMethodInvocation());
- }
- input.readMessage(subBuilder, extensionRegistry);
- setMethodInvocation(subBuilder.buildPartial());
- break;
- }
- case 26: {
- noop.model.proto.Noop.Expression.Builder subBuilder =
noop.model.proto.Noop.Expression.newBuilder();
- if (hasReturned()) {
- subBuilder.mergeFrom(getReturned());
- }
- input.readMessage(subBuilder, extensionRegistry);
- setReturned(subBuilder.buildPartial());
- break;
- }
- }
- }
- }
-
-
- // required .Statement.Type type = 1;
- public boolean hasType() {
- return result.hasType();
- }
- public noop.model.proto.Noop.Statement.Type getType() {
- return result.getType();
- }
- public Builder setType(noop.model.proto.Noop.Statement.Type value) {
- if (value == null) {
- throw new NullPointerException();
- }
- result.hasType = true;
- result.type_ = value;
- return this;
- }
- public Builder clearType() {
- result.hasType = false;
- result.type_ =
noop.model.proto.Noop.Statement.Type.METHOD_INVOCATION;
- return this;
- }
-
- // optional .MethodInvocation methodInvocation = 2;
- public boolean hasMethodInvocation() {
- return result.hasMethodInvocation();
- }
- public noop.model.proto.Noop.MethodInvocation getMethodInvocation() {
- return result.getMethodInvocation();
- }
- public Builder
setMethodInvocation(noop.model.proto.Noop.MethodInvocation value) {
- if (value == null) {
- throw new NullPointerException();
- }
- result.hasMethodInvocation = true;
- result.methodInvocation_ = value;
- return this;
- }
- public Builder
setMethodInvocation(noop.model.proto.Noop.MethodInvocation.Builder
builderForValue) {
- result.hasMethodInvocation = true;
- result.methodInvocation_ = builderForValue.build();
- return this;
- }
- public Builder
mergeMethodInvocation(noop.model.proto.Noop.MethodInvocation value) {
- if (result.hasMethodInvocation() &&
- result.methodInvocation_ !=
noop.model.proto.Noop.MethodInvocation.getDefaultInstance()) {
- result.methodInvocation_ =
-
noop.model.proto.Noop.MethodInvocation.newBuilder(result.methodInvocation_).mergeFrom(value).buildPartial();
- } else {
- result.methodInvocation_ = value;
- }
- result.hasMethodInvocation = true;
- return this;
- }
- public Builder clearMethodInvocation() {
- result.hasMethodInvocation = false;
- result.methodInvocation_ =
noop.model.proto.Noop.MethodInvocation.getDefaultInstance();
- return this;
- }
-
- // optional .Expression returned = 3;
- public boolean hasReturned() {
- return result.hasReturned();
- }
- public noop.model.proto.Noop.Expression getReturned() {
- return result.getReturned();
- }
- public Builder setReturned(noop.model.proto.Noop.Expression value) {
- if (value == null) {
- throw new NullPointerException();
- }
- result.hasReturned = true;
- result.returned_ = value;
- return this;
- }
- public Builder setReturned(noop.model.proto.Noop.Expression.Builder
builderForValue) {
- result.hasReturned = true;
- result.returned_ = builderForValue.build();
- return this;
- }
- public Builder mergeReturned(noop.model.proto.Noop.Expression value)
{
- if (result.hasReturned() &&
- result.returned_ !=
noop.model.proto.Noop.Expression.getDefaultInstance()) {
- result.returned_ =
-
noop.model.proto.Noop.Expression.newBuilder(result.returned_).mergeFrom(value).buildPartial();
- } else {
- result.returned_ = value;
- }
- result.hasReturned = true;
- return this;
- }
- public Builder clearReturned() {
- result.hasReturned = false;
- result.returned_ =
noop.model.proto.Noop.Expression.getDefaultInstance();
- return this;
- }
- }

static {
noop.model.proto.Noop.getDescriptor();
@@ -5884,6 +5410,8 @@
CONDITIONAL(5, 6),
DEREFERENCE(6, 7),
INDEX(7, 8),
+ METHOD_INVOCATION(8, 9),
+ RETURN(9, 10),
;


@@ -5899,6 +5427,8 @@
case 6: return CONDITIONAL;
case 7: return DEREFERENCE;
case 8: return INDEX;
+ case 9: return METHOD_INVOCATION;
+ case 10: return RETURN;
default: return null;
}
}
@@ -5929,7 +5459,7 @@
}

private static final Type[] VALUES = {
- EVALUATED, BOOLEAN_LITERAL, STRING_LITERAL, NUMBER_LITERAL,
IDENTIFIER, CONDITIONAL, DEREFERENCE, INDEX,
+ EVALUATED, BOOLEAN_LITERAL, STRING_LITERAL, NUMBER_LITERAL,
IDENTIFIER, CONDITIONAL, DEREFERENCE, INDEX, METHOD_INVOCATION, RETURN,
};
public static Type valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
@@ -5992,6 +5522,13 @@
private noop.model.proto.Noop.Expression rhs_ =
noop.model.proto.Noop.Expression.getDefaultInstance();
public boolean hasRhs() { return hasRhs; }
public noop.model.proto.Noop.Expression getRhs() { return rhs_; }
+
+ // optional .MethodInvocation methodInvocation = 7;
+ public static final int METHODINVOCATION_FIELD_NUMBER = 7;
+ private boolean hasMethodInvocation;
+ private noop.model.proto.Noop.MethodInvocation methodInvocation_ =
noop.model.proto.Noop.MethodInvocation.getDefaultInstance();
+ public boolean hasMethodInvocation() { return hasMethodInvocation; }
+ public noop.model.proto.Noop.MethodInvocation getMethodInvocation() {
return methodInvocation_; }

public final boolean isInitialized() {
if (!hasType) return false;
@@ -6001,6 +5538,9 @@
if (hasRhs()) {
if (!getRhs().isInitialized()) return false;
}
+ if (hasMethodInvocation()) {
+ if (!getMethodInvocation().isInitialized()) return false;
+ }
return true;
}

@@ -6024,6 +5564,9 @@
if (hasRhs()) {
output.writeMessage(6, getRhs());
}
+ if (hasMethodInvocation()) {
+ output.writeMessage(7, getMethodInvocation());
+ }
getUnknownFields().writeTo(output);
}

@@ -6057,6 +5600,10 @@
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(6, getRhs());
}
+ if (hasMethodInvocation()) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeMessageSize(7, getMethodInvocation());
+ }
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -6224,6 +5771,9 @@
if (other.hasRhs()) {
mergeRhs(other.getRhs());
}
+ if (other.hasMethodInvocation()) {
+ mergeMethodInvocation(other.getMethodInvocation());
+ }
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@@ -6289,6 +5839,15 @@
setRhs(subBuilder.buildPartial());
break;
}
+ case 58: {
+ noop.model.proto.Noop.MethodInvocation.Builder subBuilder =
noop.model.proto.Noop.MethodInvocation.newBuilder();
+ if (hasMethodInvocation()) {
+ subBuilder.mergeFrom(getMethodInvocation());
+ }
+ input.readMessage(subBuilder, extensionRegistry);
+ setMethodInvocation(subBuilder.buildPartial());
+ break;
+ }
}
}
}
@@ -6445,6 +6004,43 @@
result.rhs_ =
noop.model.proto.Noop.Expression.getDefaultInstance();
return this;
}
+
+ // optional .MethodInvocation methodInvocation = 7;
+ public boolean hasMethodInvocation() {
+ return result.hasMethodInvocation();
+ }
+ public noop.model.proto.Noop.MethodInvocation getMethodInvocation() {
+ return result.getMethodInvocation();
+ }
+ public Builder
setMethodInvocation(noop.model.proto.Noop.MethodInvocation value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ result.hasMethodInvocation = true;
+ result.methodInvocation_ = value;
+ return this;
+ }
+ public Builder
setMethodInvocation(noop.model.proto.Noop.MethodInvocation.Builder
builderForValue) {
+ result.hasMethodInvocation = true;
+ result.methodInvocation_ = builderForValue.build();
+ return this;
+ }
+ public Builder
mergeMethodInvocation(noop.model.proto.Noop.MethodInvocation value) {
+ if (result.hasMethodInvocation() &&
+ result.methodInvocation_ !=
noop.model.proto.Noop.MethodInvocation.getDefaultInstance()) {
+ result.methodInvocation_ =
+
noop.model.proto.Noop.MethodInvocation.newBuilder(result.methodInvocation_).mergeFrom(value).buildPartial();
+ } else {
+ result.methodInvocation_ = value;
+ }
+ result.hasMethodInvocation = true;
+ return this;
+ }
+ public Builder clearMethodInvocation() {
+ result.hasMethodInvocation = false;
+ result.methodInvocation_ =
noop.model.proto.Noop.MethodInvocation.getDefaultInstance();
+ return this;
+ }
}

static {
@@ -6825,11 +6421,6 @@
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_Block_fieldAccessorTable;
private static com.google.protobuf.Descriptors.Descriptor
- internal_static_Statement_descriptor;
- private static
- com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internal_static_Statement_fieldAccessorTable;
- private static com.google.protobuf.Descriptors.Descriptor
internal_static_MethodInvocation_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
@@ -6878,25 +6469,23 @@
"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"
+ ".Expression\"(\n\005Block\022\037\n\nexpression\030\001 \003(\013" +
+ "2\013.Expression\"[\n\020MethodInvocation\022\030\n\003lhs" +
+ "\030\001 \002(\0132\013.Expression\022\016\n\006method\030\002
\002(\t\022\035\n\010a" +
+ "rgument\030\003 \003(\0132\013.Expression\"\374\002\n\nExpressio" +
+ "n\022\036\n\004type\030\001
\002(\0162\020.Expression.Type\022\022\n\nboo",
+ "leanVal\030\002 \001(\010\022\021\n\tstringVal\030\003
\001(\t\022\021\n\tnumb" +
+ "erVal\030\004 \001(\r\022\030\n\003lhs\030\005
\001(\0132\013.Expression\022\030\n" +
+ "\003rhs\030\006 \001(\0132\013.Expression\022+\n\020methodInvocat" +
+ "ion\030\007
\001(\0132\021.MethodInvocation\"\262\001\n\004Type\022\r\n" +
+ "\tEVALUATED\020\001\022\023\n\017BOOLEAN_LITERAL\020\002\022\022\n\016STR"
+
+ "ING_LITERAL\020\003\022\022\n\016NUMBER_LITERAL\020\004\022\016\n\nIDE"
+
+ "NTIFIER\020\005\022\017\n\013CONDITIONAL\020\006\022\017\n\013DEREFERENC"
+
+ "E\020\007\022\t\n\005INDEX\020\010\022\025\n\021METHOD_INVOCATION\020\t\022\n\n"
+
+ "\006RETURN\020\n\"6\n\010Unittest\022\023\n\013description\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\020noop.model.pro"
+
+ "to"
};

com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner
assigner =
new
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner()
{
@@ -6988,19 +6577,11 @@
internal_static_Block_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Block_descriptor,
- new java.lang.String[] { "Statement", },
+ new java.lang.String[] { "Expression", },
noop.model.proto.Noop.Block.class,
noop.model.proto.Noop.Block.Builder.class);
- internal_static_Statement_descriptor =
- getDescriptor().getMessageTypes().get(11);
- internal_static_Statement_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessage.FieldAccessorTable(
- internal_static_Statement_descriptor,
- new java.lang.String[]
{ "Type", "MethodInvocation", "Returned", },
- noop.model.proto.Noop.Statement.class,
- noop.model.proto.Noop.Statement.Builder.class);
internal_static_MethodInvocation_descriptor =
- getDescriptor().getMessageTypes().get(12);
+ getDescriptor().getMessageTypes().get(11);
internal_static_MethodInvocation_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_MethodInvocation_descriptor,
@@ -7008,15 +6589,15 @@
noop.model.proto.Noop.MethodInvocation.class,
noop.model.proto.Noop.MethodInvocation.Builder.class);
internal_static_Expression_descriptor =
- getDescriptor().getMessageTypes().get(13);
+ getDescriptor().getMessageTypes().get(12);
internal_static_Expression_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Expression_descriptor,
- new java.lang.String[]
{ "Type", "BooleanVal", "StringVal", "NumberVal", "Lhs", "Rhs", },
+ new java.lang.String[]
{ "Type", "BooleanVal", "StringVal", "NumberVal", "Lhs", "Rhs", "MethodInvocation",
},
noop.model.proto.Noop.Expression.class,
noop.model.proto.Noop.Expression.Builder.class);
internal_static_Unittest_descriptor =
- getDescriptor().getMessageTypes().get(14);
+ getDescriptor().getMessageTypes().get(13);
internal_static_Unittest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_Unittest_descriptor,
=======================================
--- /core/src/main/proto/noop.proto Fri Dec 11 00:03:26 2009
+++ /core/src/main/proto/noop.proto Mon Dec 14 22:38:11 2009
@@ -76,20 +76,7 @@
}

message Block {
- repeated Statement statement = 1;
-}
-
-message Statement {
- enum Type {
- METHOD_INVOCATION = 1;
- RETURN_STATEMENT = 2;
- }
- // identifies which sort of statement this is
- required Type type = 1;
-
- // only one of the following should be set
- optional MethodInvocation methodInvocation = 2;
- optional Expression returned = 3;
+ repeated Expression expression = 1;
}

message MethodInvocation {
@@ -108,6 +95,8 @@
CONDITIONAL = 6;
DEREFERENCE = 7;
INDEX = 8;
+ METHOD_INVOCATION = 9;
+ RETURN = 10;
}
// identifies what sort of expression this is
required Type type = 1;
@@ -118,6 +107,7 @@
optional uint32 numberVal = 4; // TODO(alexeagle): need to store floats
too
optional Expression lhs = 5;
optional Expression rhs = 6;
+ optional MethodInvocation methodInvocation = 7;
}

message Unittest {
=======================================
--- /core/src/main/scala/noop/model/AliasDefinition.scala Thu Dec 10
22:06:44 2009
+++ /core/src/main/scala/noop/model/AliasDefinition.scala Mon Dec 14
22:38:11 2009
@@ -5,4 +5,4 @@
/**
* @author alex...@google.com (Alex Eagle)
*/
-class AliasDefinition(val data: Alias) extends ClassDefinition
+class AliasDefinition(data: Alias)
=======================================
--- /core/src/main/scala/noop/model/BindingDeclaration.scala Fri Dec 11
00:03:26 2009
+++ /core/src/main/scala/noop/model/BindingDeclaration.scala Mon Dec 14
22:38:11 2009
@@ -21,7 +21,7 @@
* AST model element which represents a declaration of a binding from a
type to an expression.
* @author alex...@google.com (Alex Eagle)
*/
-class BindingDeclaration(val data: BindOperator) extends Expression {
+class BindingDeclaration(data: BindOperator) extends Expression {

def noopType: String = data.getType;
def boundTo: Expression = ExpressionConverter.fromData(data.getBoundTo);
=======================================
--- /core/src/main/scala/noop/model/BindingDefinition.scala Fri Dec 11
00:03:26 2009
+++ /core/src/main/scala/noop/model/BindingDefinition.scala Mon Dec 14
22:38:11 2009
@@ -22,6 +22,6 @@
* AST element representing a top-level bindings definition
* @author Alex Eagle (alex...@google.com)
*/
-class BindingDefinition(val data: Binding) extends ClassDefinition() {
+class BindingDefinition(data: Binding) {
def bindings: Seq[BindingDeclaration] =
Buffer(data.getBlock.getBindList).map(b => new BindingDeclaration(b));
}
=======================================
--- /core/src/main/scala/noop/model/Block.scala Fri Dec 11 00:03:26 2009
+++ /core/src/main/scala/noop/model/Block.scala Mon Dec 14 22:38:11 2009
@@ -22,7 +22,7 @@
* @author alex...@google.com (Alex Eagle)
* @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
*/
-class Block(val data: Noop.Block) extends Expression {
+class Block(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 Fri Dec 11
00:03:26 2009
+++ /core/src/main/scala/noop/model/ClassDefinition.scala Mon Dec 14
22:38:11 2009
@@ -18,4 +18,6 @@
/**
* @author alex...@google.com (Alex Eagle)
*/
-trait ClassDefinition
+trait ClassDefinition {
+ def name: String;
+}
=======================================
--- /core/src/main/scala/noop/model/ConcreteClassDefinition.scala Fri Dec
11 00:03:26 2009
+++ /core/src/main/scala/noop/model/ConcreteClassDefinition.scala Mon Dec
14 22:38:11 2009
@@ -26,11 +26,11 @@
* @author Alex Eagle (alex...@google.com)
*/

-class ConcreteClassDefinition(val data: ConcreteClass) extends
ClassDefinition {
+class ConcreteClassDefinition(data: ConcreteClass) extends ClassDefinition
{
def properties: Seq[Property] = Buffer(data.getPropertyList);
def name: String = data.getName;
- def unittests: Seq[Unittest] = Buffer(data.getUnittestList);
-
+ def unittests: Seq[UnittestDefinition] =
Buffer(data.getUnittestList).map(u => new UnittestDefinition(u));
+
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/InterfaceDefinition.scala Fri Dec 11
00:03:26 2009
+++ /core/src/main/scala/noop/model/InterfaceDefinition.scala Mon Dec 14
22:38:11 2009
@@ -22,4 +22,6 @@
* @author Alex Eagle (alex...@google.com)
*/

-class InterfaceDefinition(val data: Interface) extends ClassDefinition
+class InterfaceDefinition(data: Interface) extends ClassDefinition {
+ def name: String = data.getName;
+}
=======================================
--- /core/src/main/scala/noop/model/MethodDefinition.scala Fri Dec 11
00:03:26 2009
+++ /core/src/main/scala/noop/model/MethodDefinition.scala Mon Dec 14
22:38:11 2009
@@ -24,7 +24,7 @@
* @author alex...@google.com (Alex Eagle)
* @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
*/
-class MethodDefinition(val data: Method) {
+class MethodDefinition(data: Method) extends Invokable {
def name:String = data.getSignature.getName;
def parameters: Seq[Property] =
Buffer(data.getSignature.getArgumentList);
def modifiers: Seq[Modifier] = Buffer(data.getSignature.getModifierList);
=======================================
--- /core/src/main/scala/noop/model/UnittestDefinition.scala Fri Dec 11
00:03:26 2009
+++ /core/src/main/scala/noop/model/UnittestDefinition.scala Mon Dec 14
22:38:11 2009
@@ -1,9 +1,12 @@
package noop.model

-import proto.Noop.Unittest
+import proto.Noop.{Property, Unittest}

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

-class UnittestDefinition(val data: Unittest)
+class UnittestDefinition(val data: Unittest) extends Invokable {
+ def parameters: Seq[Property] = List();
+ def name: String = data.getDescription;
+}
=======================================
--- /core/src/main/scala/noop/model/Visitor.scala Thu Dec 10 22:06:44 2009
+++ /core/src/main/scala/noop/model/Visitor.scala Mon Dec 14 22:38:11 2009
@@ -59,4 +59,6 @@
def visit(conditionalAndExpression: ConditionalAndExpression);

def visit(conditionalOrExpression: ConditionalOrExpression);
-}
+
+ def visit(invokable: Invokable) = { throw new
UnsupportedOperationException("should only visit method or test"); }
+}
=======================================
--- /core/src/main/scala/noop/model/persistence/ClassRepository.scala Thu
Dec 10 22:06:44 2009
+++ /core/src/main/scala/noop/model/persistence/ClassRepository.scala Mon
Dec 14 22:38:11 2009
@@ -1,18 +1,22 @@
package noop.model.persistence;

-import noop.model.proto.Noop.ConcreteClass
import com.google.protobuf.TextFormat
import java.io.{InputStreamReader, InputStream}
-import noop.model.{ConcreteClassDefinition, ClassDefinition}
+import noop.model.proto.Noop.{Module, ConcreteClass}
+import noop.model.{ModuleDefinition, ConcreteClassDefinition,
ClassDefinition}
+import collection.jcl.Buffer


/**
* @author alex...@google.com (Alex Eagle)
*/
-class ClassRepository {
- def getClassDefinition(stream: InputStream): ConcreteClassDefinition = {
- val builder = ConcreteClass.newBuilder();
- TextFormat.merge(new InputStreamReader(stream), builder);
- new ConcreteClassDefinition(builder.build());
+class ClassRepository(modules: Seq[Module]) {
+ def getConcreteClassDefinition(name: String): ConcreteClassDefinition = {
+ return modules.find((m: Module) =>
+ Buffer(m.getConcreteClassList).find((c: ConcreteClass) =>
+ c.getName == name).isDefined) match {
+ case Some(module) => new ModuleDefinition(module).findClass(name);
+ case None => throw new ClassNotFoundException("Class " + name + "
not found in any module");
+ }
}
}
=======================================
--- /core/src/test/java/noop/model/proto/ProtoBufferSpike.java Fri Dec 11
00:03:26 2009
+++ /core/src/test/java/noop/model/proto/ProtoBufferSpike.java Mon Dec 14
22:38:11 2009
@@ -6,9 +6,8 @@
import noop.model.proto.Noop.*;

import static noop.model.proto.Noop.Expression.Type.IDENTIFIER;
+import static noop.model.proto.Noop.Expression.Type.RETURN;
import static noop.model.proto.Noop.Expression.Type.STRING_LITERAL;
-import static noop.model.proto.Noop.Statement.Type.METHOD_INVOCATION;
-import static noop.model.proto.Noop.Statement.Type.RETURN_STATEMENT;

/**
* Utility class used for experimenting with serializing the Noop AST to
protocol buffer.
@@ -39,15 +38,14 @@
.setDocumentation("the entry point of the application")
.addReturnType("noop.Int"))
.setBlock(Block.newBuilder()
- .addStatement(Statement.newBuilder()
- .setType(METHOD_INVOCATION)
+ .addExpression(Expression.newBuilder()
.setMethodInvocation(MethodInvocation.newBuilder()
.setLhs(Expression.newBuilder().setType(IDENTIFIER).setStringVal("console"))
.setMethod("println")
.addArgument(Expression.newBuilder().setType(STRING_LITERAL).setStringVal("hello"))))
- .addStatement(Statement.newBuilder()
- .setType(RETURN_STATEMENT)
- .setReturned(Expression.newBuilder().setNumberVal(0)))))
+ .addExpression(Expression.newBuilder()
+ .setType(RETURN)
+ .setRhs(Expression.newBuilder().setNumberVal(0)))))
.addUnittest(Unittest.newBuilder().setDescription("should
print the first argument"))
.addUnittest(Unittest.newBuilder().setDescription("should
return zero"))
).build();

==============================================================================
Revision: 3757d8234f
Author: Alex Eagle <aeagl...@gmail.com>
Date: Mon Dec 14 22:46:07 2009
Log: Replace the noop stdlib in source files with the corresponding pure
AST.
http://code.google.com/p/noop/source/detail?r=3757d8234f

Added:
/interpreter/src/main/scala/noop/stdlib/StdLibModuleBuilder.scala
Deleted:
/interpreter/src/main/noop/noop/Boolean.noop
/interpreter/src/main/noop/noop/Console.noop
/interpreter/src/main/noop/noop/Int.noop
/interpreter/src/main/noop/noop/Object.noop
/interpreter/src/main/noop/noop/String.noop
/interpreter/src/main/noop/noop/system/RawCommandLineArguments.noop

=======================================
--- /dev/null
+++ /interpreter/src/main/scala/noop/stdlib/StdLibModuleBuilder.scala Mon
Dec 14 22:46:07 2009
@@ -0,0 +1,99 @@
+package noop.stdlib
+
+import noop.model.proto.Noop._
+import noop.model.ConcreteClassDefinition
+
+/**
+ * Temporary home for the standard libraries, so they don't need to be
parsed from source.
+ * @author alex...@google.com (Alex Eagle)
+ */
+class StdLibModuleBuilder {
+ def build: Module = {
+ Module.newBuilder
+ .addConcreteClass(booleanClass)
+ .addConcreteClass(consoleClass)
+ .addConcreteClass(intClass)
+ .addConcreteClass(objectClass)
+ .build();
+ }
+
+ def objectClass =
ConcreteClass.newBuilder.setName("noop.Object").build();
+
+ def stringClass = ConcreteClass.newBuilder
+ .setName("noop.String")
+ .addMethod(toStringMethod)
+ .addMethod(Method.newBuilder
+ .setSignature(MethodSignature.newBuilder
+ .setName("length")
+ .addReturnType("noop.Int")
+ .addModifier(Modifier.NATIVE)));
+
+ def consoleClass = ConcreteClass.newBuilder
+ .setName("noop.system.Console")
+ .addMethod(Method.newBuilder
+ .setSignature(MethodSignature.newBuilder
+ .setName("println")
+ .addArgument(Property.newBuilder
+ .setName("str")
+ .setType("noop.String"))));
+
+ def intClass: ConcreteClass.Builder = {
+ val intClass = ConcreteClass.newBuilder.setName("noop.Int");
+
+ for (arithmetic <-
List("plus", "minus", "multiply", "divide", "modulo")) {
+ intClass.addMethod(Method.newBuilder
+ .setSignature(MethodSignature.newBuilder
+ .setName(arithmetic)
+ .addReturnType("noop.Int")
+ .addModifier(Modifier.NATIVE)
+ .addArgument(Property.newBuilder
+ .setName("other")
+ .setType("noop.Int"))));
+ }
+
+ for (logic <-
List("equals", "doesNotEqual", "greaterThan", "lesserThan", "greaterOrEqualThan", "lesserOrEqualThan"))
{
+ intClass.addMethod(Method.newBuilder
+ .setSignature(MethodSignature.newBuilder
+ .setName(logic)
+ .addReturnType("noop.Boolean")
+ .addModifier(Modifier.NATIVE)
+ .addArgument(Property.newBuilder
+ .setName("other")
+ .setType("noop.Int"))));
+ }
+
+ intClass.addMethod(toStringMethod);
+
+ return intClass;
+ }
+
+ def toStringMethod = Method.newBuilder
+ .setSignature(MethodSignature.newBuilder
+ .setName("toString")
+ .addReturnType("noop.String")
+ .addModifier(Modifier.NATIVE));
+
+ def booleanClass: ConcreteClass.Builder = {
+ val booleanClass = ConcreteClass.newBuilder.setName("noop.Boolean");
+
+ for (logic <- List("and", "or", "xor")) {
+ booleanClass.addMethod(Method.newBuilder
+ .setSignature(MethodSignature.newBuilder
+ .setName(logic)
+ .addModifier(Modifier.NATIVE)
+ .addReturnType("noop.Boolean")
+ .addArgument(Property.newBuilder
+ .setName("other")
+ .setType("noop.Boolean"))));
+ }
+
+ booleanClass.addMethod(Method.newBuilder
+ .setSignature(MethodSignature.newBuilder
+ .setName("not")
+ .addModifier(Modifier.NATIVE)
+ .addReturnType("noop.Boolean")));
+
+ booleanClass.addMethod(toStringMethod);
+ return booleanClass;
+ }
+}
=======================================
--- /interpreter/src/main/noop/noop/Boolean.noop Fri Nov 13 11:55:04 2009
+++ /dev/null
@@ -1,23 +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.
- */
-
-class Boolean() {
- native Boolean and(Boolean other) {}
- native Boolean or(Boolean other) {}
- native Boolean xor(Boolean other) {}
- native Boolean not() {}
- native String toString() {}
-}
=======================================
--- /interpreter/src/main/noop/noop/Console.noop Fri Nov 13 16:27:54 2009
+++ /dev/null
@@ -1,19 +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.
- */
-
-class Console() {
- native Void println(String str) {}
-}
=======================================
--- /interpreter/src/main/noop/noop/Int.noop Thu Dec 3 18:36:36 2009
+++ /dev/null
@@ -1,30 +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.
- */
-
-class Int() {
- native Int plus(Int other) {}
- native Int minus(Int other) {}
- native Int multiply(Int other) {}
- native Int divide(Int other) {}
- native Int modulo(Int other) {}
- native Boolean equals(Object other) {}
- native Boolean doesNotEqual(Object other) {}
- native Boolean greaterThan(Object other) {}
- native Boolean lesserThan(Object other) {}
- native Boolean greaterOrEqualThan(Object other) {}
- native Boolean lesserOrEqualThan(Object other) {}
- native String toString() {}
-}
=======================================
--- /interpreter/src/main/noop/noop/Object.noop Fri Nov 13 11:55:04 2009
+++ /dev/null
@@ -1,19 +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.
- */
-
-class Object() {
-
-}
=======================================
--- /interpreter/src/main/noop/noop/String.noop Fri Nov 13 11:55:04 2009
+++ /dev/null
@@ -1,21 +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.
- */
-
-class String() {
- native Int length() {}
- // TODO(alexeagle): this shouldn't need to be native, just return this
- native String toString() {}
-}
=======================================
--- /interpreter/src/main/noop/noop/system/RawCommandLineArguments.noop Sat
Dec 5 16:49:22 2009
+++ /dev/null
@@ -1,20 +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.
- */
-
- """
- Provides access to the command line arguments exactly as they were
provided to the program.
-"""
-class RawCommandLineArguments() {}
Reply all
Reply to author
Forward
0 new messages