Copyright (C) 2013 Madis Pink
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softwa...
If you think the Android project bad listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.madisp.bad.expr;
/*fromwww.java2s.com*/import com.madisp.bad.eval.BadConverter;
import com.madisp.bad.eval.Scope;
import com.madisp.bad.eval.Watcher;
/**
* Created with IntelliJ IDEA.
* User: madis
* Date: 3/23/13
* Time: 1:57 PM
*/publicclass MethodExpression extends BasableExpression {
String m;
Expression[] args;
public MethodExpression(String m, Expression... args) {
super(null);
this.m = m;
this.args = args;
}
@Override
public Object value(Scope scope) {
Object[] argvalues = new Object[args.length];
for (int i = 0; i < argvalues.length; i++) {
argvalues[i] = BadConverter.object(args[i].value(scope));
}
if (!hasBase()) {
return scope.callMethod(null, m, argvalues);
}
Object base = getBase(scope);
if (base != null) {
return scope.callMethod(base, m, argvalues);
}
return null;
}
@Override
publicvoid addWatcher(Scope scope, Watcher w) {
super.addWatcher(scope, w);
for (Expression arg : args) {
arg.addWatcher(scope, w);
}
}
}