Skip to content

Commit

Permalink
ASG module procedure api
Browse files Browse the repository at this point in the history
  • Loading branch information
uwol committed Aug 17, 2017
1 parent 70e72b1 commit b398660
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 11 deletions.
12 changes: 12 additions & 0 deletions src/main/java/io/proleap/vb6/asg/metamodel/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,31 @@ public enum OptionCompare {

Function getFunction(String name);

List<Function> getFunctions();

List<String> getLines();

List<Procedure> getProcedures();

@Override
Program getProgram();

PropertyGet getPropertyGet(String name);

List<PropertyGet> getPropertyGets();

PropertyLet getPropertyLet(String name);

List<PropertyLet> getPropertyLets();

PropertySet getPropertySet(String name);

List<PropertySet> getPropertySets();

Sub getSub(String name);

List<Sub> getSubs();

io.proleap.vb6.asg.metamodel.Type getType(String name);

Double getVersion();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/proleap/vb6/asg/metamodel/Procedure.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
import io.proleap.vb6.VisualBasic6Parser.ArgContext;
import io.proleap.vb6.VisualBasic6Parser.ArgDefaultValueContext;
import io.proleap.vb6.asg.metamodel.call.Call;
import io.proleap.vb6.asg.metamodel.statement.Statement;
import io.proleap.vb6.asg.metamodel.type.Type;

public interface Procedure extends Scope, Declaration, VisibilityElement {
public interface Procedure extends Scope, Declaration, Statement, VisibilityElement {

Arg addArg(ArgContext ctx);

Expand Down
40 changes: 40 additions & 0 deletions src/main/java/io/proleap/vb6/asg/metamodel/impl/ModuleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.util.List;
import java.util.Map;

import com.google.common.collect.Lists;

import io.proleap.vb6.VisualBasic6Parser.ArgContext;
import io.proleap.vb6.VisualBasic6Parser.AttributeStmtContext;
import io.proleap.vb6.VisualBasic6Parser.DeclareStmtContext;
Expand All @@ -38,6 +40,7 @@
import io.proleap.vb6.asg.metamodel.Literal;
import io.proleap.vb6.asg.metamodel.Module;
import io.proleap.vb6.asg.metamodel.ModuleConfigElement;
import io.proleap.vb6.asg.metamodel.Procedure;
import io.proleap.vb6.asg.metamodel.ProcedureDeclaration;
import io.proleap.vb6.asg.metamodel.Program;
import io.proleap.vb6.asg.metamodel.ScopedElement;
Expand Down Expand Up @@ -90,6 +93,8 @@ public abstract class ModuleImpl extends ScopeImpl implements Module {

protected Boolean optionPrivateModule;

protected List<Procedure> procedures = new ArrayList<Procedure>();

protected final Program program;

protected Map<String, PropertyGet> propertyGets = new HashMap<String, PropertyGet>();
Expand Down Expand Up @@ -244,6 +249,7 @@ public Function addFunction(final FunctionStmtContext ctx) {

registerStatement(result);
functions.put(name, result);
procedures.add(result);

if (ctx.argList() != null) {
for (final ArgContext argCtx : ctx.argList().arg()) {
Expand Down Expand Up @@ -334,6 +340,7 @@ public PropertyGet addPropertyGet(final PropertyGetStmtContext ctx) {

registerStatement(result);
propertyGets.put(name, result);
procedures.add(result);

if (ctx.argList() != null) {
for (final ArgContext argCtx : ctx.argList().arg()) {
Expand Down Expand Up @@ -369,6 +376,7 @@ public PropertyLet addPropertyLet(final PropertyLetStmtContext ctx) {

registerStatement(result);
propertyLets.put(name, result);
procedures.add(result);

if (ctx.argList() != null) {
for (final ArgContext argCtx : ctx.argList().arg()) {
Expand All @@ -392,6 +400,7 @@ public PropertySet addPropertySet(final PropertySetStmtContext ctx) {

registerStatement(result);
propertySets.put(name, result);
procedures.add(result);

if (ctx.argList() != null) {
for (final ArgContext argCtx : ctx.argList().arg()) {
Expand All @@ -415,6 +424,7 @@ public Sub addSub(final SubStmtContext ctx) {

registerStatement(result);
subs.put(name, result);
procedures.add(result);

if (ctx.argList() != null) {
for (final ArgContext argCtx : ctx.argList().arg()) {
Expand Down Expand Up @@ -502,6 +512,11 @@ public Function getFunction(final String name) {
return functions.get(name);
}

@Override
public List<Function> getFunctions() {
return Lists.newArrayList(functions.values());
}

@Override
public List<String> getLines() {
return lines;
Expand All @@ -512,6 +527,11 @@ public String getName() {
return name;
}

@Override
public List<Procedure> getProcedures() {
return procedures;
}

@Override
public Program getProgram() {
return program;
Expand All @@ -522,16 +542,31 @@ public PropertyGet getPropertyGet(final String name) {
return propertyGets.get(name);
}

@Override
public List<PropertyGet> getPropertyGets() {
return Lists.newArrayList(propertyGets.values());
}

@Override
public PropertyLet getPropertyLet(final String name) {
return propertyLets.get(name);
}

@Override
public List<PropertyLet> getPropertyLets() {
return Lists.newArrayList(propertyLets.values());
}

@Override
public PropertySet getPropertySet(final String name) {
return propertySets.get(name);
}

@Override
public List<PropertySet> getPropertySets() {
return Lists.newArrayList(propertySets.values());
}

@Override
public List<ScopedElement> getScopedElementsInScope(final String name) {
final List<ScopedElement> result;
Expand All @@ -553,6 +588,11 @@ public Sub getSub(final String name) {
return subs.get(name);
}

@Override
public List<Sub> getSubs() {
return Lists.newArrayList(subs.values());
}

@Override
public io.proleap.vb6.asg.metamodel.Type getType(final String name) {
return types.get(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
import io.proleap.vb6.VisualBasic6Parser.FunctionStmtContext;
import io.proleap.vb6.asg.metamodel.Procedure;
import io.proleap.vb6.asg.metamodel.call.FunctionCall;
import io.proleap.vb6.asg.metamodel.statement.Statement;
import io.proleap.vb6.asg.metamodel.type.AssignableTypedElement;

/**
* Declares the name, arguments, and code that form the body of a Function
* procedure.
*/
public interface Function extends Procedure, Statement, AssignableTypedElement {
public interface Function extends Procedure, AssignableTypedElement {

void addFunctionCall(FunctionCall functionCall);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
import io.proleap.vb6.VisualBasic6Parser.PropertyGetStmtContext;
import io.proleap.vb6.asg.metamodel.Procedure;
import io.proleap.vb6.asg.metamodel.call.PropertyGetCall;
import io.proleap.vb6.asg.metamodel.statement.Statement;
import io.proleap.vb6.asg.metamodel.type.AssignableTypedElement;

/**
* Declares the name, arguments, and code that form the body of a Property
* procedure, which gets the value of a property.
*/
public interface PropertyGet extends Procedure, Statement, AssignableTypedElement {
public interface PropertyGet extends Procedure, AssignableTypedElement {

void addPropertyGetCall(PropertyGetCall propertyGetCall);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
import io.proleap.vb6.VisualBasic6Parser.PropertyLetStmtContext;
import io.proleap.vb6.asg.metamodel.Procedure;
import io.proleap.vb6.asg.metamodel.call.PropertyLetCall;
import io.proleap.vb6.asg.metamodel.statement.Statement;

/**
* Declares the name, arguments, and code that form the body of a Property Let
* procedure, which assigns a value to a property.
*/
public interface PropertyLet extends Procedure, Statement {
public interface PropertyLet extends Procedure {

void addPropertyLetCall(PropertyLetCall propertyLetCall);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
import io.proleap.vb6.VisualBasic6Parser.PropertySetStmtContext;
import io.proleap.vb6.asg.metamodel.Procedure;
import io.proleap.vb6.asg.metamodel.call.PropertySetCall;
import io.proleap.vb6.asg.metamodel.statement.Statement;

/**
* Declares the name, arguments, and code that form the body of a Property
* procedure, which sets a reference to an object.
*/
public interface PropertySet extends Procedure, Statement {
public interface PropertySet extends Procedure {

void addPropertySetCall(PropertySetCall propertySetCall);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
import io.proleap.vb6.VisualBasic6Parser.SubStmtContext;
import io.proleap.vb6.asg.metamodel.Procedure;
import io.proleap.vb6.asg.metamodel.call.SubCall;
import io.proleap.vb6.asg.metamodel.statement.Statement;

/**
* Declares the name, arguments, and code that form the body of a Sub procedure.
*/
public interface Sub extends Procedure, Statement {
public interface Sub extends Procedure {

void addSubCall(SubCall subCall);

Expand Down

0 comments on commit b398660

Please sign in to comment.