/* * Copyright 2011 eBay Software Foundation * * 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. */ 'use strict'; var createError = require('raptor-util').createError; var nodePath = require('path'); var stringify = require('raptor-json/stringify'); var StringBuilder = require('raptor-strings/StringBuilder'); var Expression = require('./Expression'); var arrayFromArguments = require('raptor-util').arrayFromArguments; var INDENT = ' '; function writeArg(writer, arg) { if (typeof arg === 'string') { writer._code.append(arg); } else if (typeof arg === 'boolean') { writer._code.append(arg ? 'true' : 'false'); } else if (typeof arg === 'function') { arg(); } else if (arg instanceof Expression) { writer._code.append(arg.toString()); } else if (arg) { writer._code.append(arg.toString()); } else { throw createError(new Error('Illegal arg: ' + arg.toString())); } } function writeArgs(writer, args) { for (var i=0, len=args.length; i